/**
 * @version 1.0.0.0
 * @copyright Copyright ©  2013
 * @compiler Bridge.NET 15.6.0
 */
Bridge.assembly("JSLib", function ($asm, globals) {
    "use strict";

    Bridge.define("BasePageEx", {
        statics: {
            DataBind: function (page, data) {
                return JSLib.Data.DataBindHelper.Bind(data, page.UniqueId);
            }
        }
    });

    Bridge.define("BusinessFormatter", {
        statics: {
            FormatStr: function (data) {
                if (Bridge.is(data, Date)) {
                    return DateTimeEx.FakeDateTimeToStr(data);
                }
                return data.toString();
            }
        }
    });

    Bridge.define("ConsoleEx", {
        statics: {
            Dump: function (T, target, description) {
                if (description === void 0) { description = ""; }
                if (!System.String.isNullOrEmpty(description)) {
                    console.info(System.String.concat(description, ":", target));
                } else {
                    console.log(target);
                }

                return target;
            }
        }
    });

    Bridge.define("ControllerBaseEx", {
        statics: {
            DataBind: function (control, data) {
                return JSLib.Data.DataBindHelper.Bind(data, control.UniqueId);
            }
        }
    });

    Bridge.define("CoreEx", {
        statics: {
            Abs: function (data) {
                return Math.abs(data);
            },
            Abs$1: function (data) {
                return Math.abs(data);
            },
            ToInt: function (target, defaultValue) {
                if (defaultValue === void 0) { defaultValue = 0; }
                var result = parseInt(target, 10);
                if (isNaN(result)) {
                    return defaultValue;
                }
                return result;
            },
            ToIntNullable: function (target, defaultValue) {
                if (defaultValue === void 0) { defaultValue = -1; }
                if (System.String.isNullOrEmpty(target)) {
                    return null;
                }
                var result = System.Int32.parse(target);
                if (isNaN(result)) {
                    return null;
                }
                if (result === -1) {
                    return null;
                }
                return result;
            },
            ToBoolNullabel: function (target, defaultValue) {
                if (defaultValue === void 0) { defaultValue = ""; }
                if (System.String.isNullOrEmpty(target)) {
                    return null;
                }
                var result = System.Int32.parse(target);
                if (isNaN(result)) {
                    return null;
                }
                switch (result) {
                    case 0: 
                        return false;
                    case 1: 
                        return true;
                    default: 
                        return null;
                }
            },
            ToDouble: function (target) {
                return System.Double.parse(target);
            },
            ToDoubleWithDefault: function (target, defaultValue) {
                if (defaultValue === void 0) { defaultValue = 0.0; }
                if (System.String.isNullOrEmpty(target)) {
                    return defaultValue;
                }
                var result = System.Double.parse(target);
                if (isNaN(result)) {
                    return defaultValue;
                }
                return result;
            },
            ToDoubleNullable: function (target) {
                if (System.String.isNullOrEmpty(target)) {
                    return null;
                }
                var result = System.Double.parse(target);
                if (isNaN(result)) {
                    return null;
                }
                return result;
            },
            Ensure: function (target, length) {
                if (System.String.isNullOrEmpty(target)) {
                    return "";
                }

                if (target.length <= length) {
                    return target;
                }

                return System.String.concat(target.substr(0, length), "...");
            },
            ToEnumNameString: function (T, target) {
                return System.Enum.toString(T, target);
            },
            ToEnumNameString$1: function (T, target) {
                return ss.Enum.toString(T,target);
            },
            CloneBySerilization: function (T, target) {
                if (target == null) {
                    return Bridge.getDefaultValue(T);
                }
                return JSON.parse(JSON.stringify(target));
            },
            ToDebugString: function (T, target) {
                return JSON.stringify(target);
            },
            ToAbsoluteUrl: function (target) {
                if (!System.String.startsWith(target, "http") && !System.String.startsWith(target, window.location.origin)) {
                    return System.String.concat(window.location.origin, target);
                } else {
                    return target;
                }
            },
            ToPureText: function (target) {
                return $(target).text();
            },
            AsImageElement: function (target) {
                return target[0];
            },
            AsHTMLInputElement: function (target) {

                return target[0];
            },
            AppendFormat: function (target, format, value) {
                if (value === void 0) { value = []; }
                return target.append(System.String.format.apply(System.String, [format].concat(value)));
            }
        }
    });

    Bridge.define("CssEx", {
        statics: {
            PxToInt: function (target) {
                if (System.String.isNullOrEmpty(target)) {
                    return 0;
                }

                if (!System.String.endsWith(target, "px")) {
                    return 0;
                }

                var indexOfPx = System.String.indexOf(target, "px");
                return CoreEx.ToInt(target.substr(0, indexOfPx));
            }
        }
    });

    Bridge.define("DateTimeEx", {
        statics: {
            ToDateTime: function (datetimeStr) {
                var result = moment(datetimeStr)._d;
                if (isNaN(result)) {
                    return null;
                } else {
                    return result;
                }

            },
            ToDateTimeForce$1: function (datetimeStr) {
                var result = moment(datetimeStr)._d;
                return result;
            },
            ToDateTimeForce: function (dateTime) {
                var result = moment(dateTime)._d;
                return result;
            },
            ToDateStr: function (target, format) {
                if (format === void 0) { format = "yyyy-MM-dd"; }
                return DateTimeEx.ToDateString(target, format);
            },
            ToDateString: function (target, format) {
                if (format === void 0) { format = "yyyy-MM-dd"; }
                if (Bridge.equals(target, null)) {
                    return "";
                }
                var type = System.Nullable$1(Date);
                if (Bridge.referenceEquals(type, String)) {
                    target = DateTimeEx.ToDateTime(target);
                }
                if (!Bridge.equals(target, null)) {
                    return Bridge.Date.format(System.Nullable.getValue(target), format);
                }
                return "";
            },
            ToDateTimeStr: function (target, format) {
                if (format === void 0) { format = "yyyy-MM-dd HH:mm:ss"; }
                return DateTimeEx.ToDateString(target, format);
            },
            FakeDateTimeToStr: function (target, format) {
                if (format === void 0) { format = "yyyy-MM-dd HH:mm:ss"; }
                return Bridge.Date.format(DateTimeEx.ToDateTimeForce$1(target), format);
            },
            FakeDateTimeToStr$1: function (target, format) {
                if (format === void 0) { format = "yyyy-MM-dd HH:mm:ss"; }
                if (Bridge.equals(target, null)) {
                    return "";
                }
                return Bridge.Date.format(DateTimeEx.ToDateTimeForce$1(target), format);
            }
        }
    });

    Bridge.define("DateTimeExtension", {
        statics: {
            JsonDateToString: function (value, format) {
                return Bridge.Date.format(new Date(System.Int64(System.Int32.parse(System.String.replaceAll(System.String.replaceAll(Bridge.Date.format(value), "/Date(", ""), ")/", ""))).toNumber()/10000), format);
            }
        }
    });

    Bridge.define("DebugEx", {
        statics: {
            ExportMe: function (target, name) {
                var windowabc = window;
                windowabc[name] = target;
            }
        }
    });

    Bridge.define("ElementEx");

    Bridge.define("EnumImport");

    Bridge.define("FileReaderExtension", {
        statics: {
            GetFileBufferData: function (file) {
                var reader = new FileReader();
                reader.readAsArrayBuffer(file);
                var task = new System.Threading.Tasks.TaskCompletionSource();
                reader.onload = function (event) {
                    task.setResult(event.target.result);
                };
                return task.task;
            },
            GetFileBufferData$1: function (file) {
                return FileReaderExtension.GetFileBufferData(file[0].files[0]);
            },
            GetFileBinaryStringData: function (file) {
                var reader = new FileReader();
                reader.readAsBinaryString(file);
                var task = new System.Threading.Tasks.TaskCompletionSource();
                reader.onload = function (event) {
                    task.setResult(event.target.result);
                };
                return task.task;
            },
            GetFileBinaryStringData$1: function (file) {
                return FileReaderExtension.GetFileBinaryStringData(file[0].files[0]);
            },
            GetFileBase64Data: function (file) {
                var reader = new FileReader();
                reader.readAsDataURL(file);
                var task = new System.Threading.Tasks.TaskCompletionSource();
                reader.onload = function (event) {
                    var strResult = event.target.result;

                    task.setResult(StringHelper.RemoveBase64Header(strResult));
                };
                return task.task;
            },
            GetFileBase64StringData: function (file) {
                return FileReaderExtension.GetFileBase64Data(file[0].files[0]);
            },
            HasFile: function (target) {
                return target[0].files.length > 0;
            }
        }
    });

    Bridge.define("FileReaderUtil", {
        statics: {
            LoadComplete: function (target) {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                target.onload = Bridge.fn.combine(target.onload, function (arg) {
                    tsk.setResult(true);
                });
                return tsk.task;
            },
            ChooseFile: function (inputFile) {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                var handler = null;
                inputFile.val(null);
                handler = function () {
                    var $step = 0,
                        $task1, 
                        $jumpFromFinally, 
                        reader, 
                        file, 
                        $asyncBody = Bridge.fn.bind(this, function () {
                            for (;;) {
                                $step = System.Array.min([0,1], $step);
                                switch ($step) {
                                    case 0: {
                                        reader = new FileReader();
                                            file = System.Linq.Enumerable.from(inputFile[0].files).firstOrDefault(null, null);
                                            if (file == null) {
                                                tsk.setResult(null);
                                                inputFile.off("change");
                                                return;
                                            }
                                            reader.readAsDataURL(file);
                                            $task1 = FileReaderUtil.LoadComplete(reader);
                                            $step = 1;
                                            $task1.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 1: {
                                        $task1.getAwaitedResult();
                                        tsk.setResult(reader.result);
                                            inputFile.off("change");
                                        return;
                                    }
                                    default: {
                                        return;
                                    }
                                }
                            }
                        }, arguments);

                    $asyncBody();
                };
                inputFile.change(handler);
                inputFile.click();
                return tsk.task;
            }
        }
    });

    Bridge.define("FlagEnumExtension", {
        statics: {
            HasFlag$1: function (value, flagValue) {
                return (value & flagValue) === flagValue;
            },
            HasFlag: function (value, flagValue) {
                return (value & flagValue) === flagValue;
            }
        }
    });

    Bridge.define("IScrollEx", {
        statics: {
            GotoTop: function (iscroll) {
                iscroll.scrollTo(0, 0, 100, false);
            }
        }
    });

    Bridge.define("JSLib.BootStrap.BootStrapBehavior", {
        statics: {
            RegisterTabPanel: function () {
                var doc = $(document);
                doc.on("click", "ul[tabPanel]>li>a", $asm.$.JSLib.BootStrap.BootStrapBehavior.f1);
            }
        }
    });

    Bridge.ns("JSLib.BootStrap.BootStrapBehavior", $asm.$);

    Bridge.apply($asm.$.JSLib.BootStrap.BootStrapBehavior, {
        f1: function (event) {
            var target = $(event.currentTarget).parent();
            var index = target.index();
            $(target.parent().children().removeClass("active")[index]).addClass("active");
            var tabPanels = target.prev().next();
            $(tabPanels.find(".tab-pane").removeClass("active")[index]).addClass("active");
        }
    });

    Bridge.define("JSLib.CommonService", {
        statics: {
            GetString: function (bytes) {
                var $t;
                var data = new (System.Collections.Generic.List$1(System.Char))();
                $t = Bridge.getEnumerator(bytes);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    data.add(item);
                }
                return String.fromCharCode.apply(null, data.toArray());
            },
            GetBytes: function (str) {
                var $t;
                var data = new (System.Collections.Generic.List$1(System.Byte))();
                $t = Bridge.getEnumerator(str);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    data.add(item);
                }
                return data.toArray();
            }
        },
        GetCurrentPosition: function (baiduMapKey, showTurnOnGPSPrompt, showLoading) {
            if (showLoading === void 0) { showLoading = false; }
            if (showLoading) {
                JSLib.Mobile.Application.ShowLoading();
            }
            var tsk = new System.Threading.Tasks.TaskCompletionSource();
            if (JSLib.Mobile.Application.DeviceType === JSLib.Mobile.DeviceType.Iphone || JSLib.Mobile.Application.IsBrowser) {
                var point = null;
                window.navigator.geolocation.getCurrentPosition(Bridge.fn.bind(this, function (location) {
                    var $step = 0,
                        $task1, 
                        $taskResult1, 
                        location, 
                        $jumpFromFinally, 
                        result, 
                        $asyncBody = Bridge.fn.bind(this, function () {
                            for (;;) {
                                $step = System.Array.min([0,1], $step);
                                switch ($step) {
                                    case 0: {
                                        JSLib.Mobile.Application.HideLoading();
                                            $task1 = new JSLib.Map.BaiduGeocodingService().GetLocationAddress(baiduMapKey, location.coords.longitude, location.coords.latitude);
                                            $step = 1;
                                            $task1.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 1: {
                                        $taskResult1 = $task1.getAwaitedResult();
                                        result = $taskResult1;
                                            point = new JSLib.MapPoint.$ctor1(location.coords.longitude, location.coords.latitude, result);
                                            tsk.setResult(point);
                                        return;
                                    }
                                    default: {
                                        return;
                                    }
                                }
                            }
                        }, arguments);

                    $asyncBody();
                }), function (error) {
                    if (JSLib.Mobile.Application.DeviceType !== JSLib.Mobile.DeviceType.Android && showTurnOnGPSPrompt) {
                        JSLib.Mobile.MessageBox.Alert("获取位置失败，请在设置中打开GPS，并允许本软件使用GPS!");
                    }
                    JSLib.Mobile.Application.HideLoading();
                    tsk.setResult(point);
                }, Bridge.merge(new Object(), {
                    timeout: 10000
                } ));
            }
            return tsk.task;
        }
    });

    Bridge.define("JSLib.Mobile.UIBase", {
        contentBuilder: null,
        pageObject: null,
        iscrollContainers: null,
        iscrollListContainers: null,
        UniqueId: null,
        config: {
            events: {
                OnOrientationChange: null
            },
            init: function () {
                this.contentBuilder = new System.Text.StringBuilder();
                this.iscrollContainers = new (System.Collections.Generic.List$1(JSLib.IScrollWraper.IScrollContainer))();
                this.iscrollListContainers = new (System.Collections.Generic.List$1(JSLib.IScrollWraper.IScrollList))();
                this.UniqueId = System.Guid.newGuid().toString();
            }
        },
        ctor: function () {
            this.$initialize();
            if (window.screen.orientation == null) {
                return;
            }
            window.screen.orientation.addEventListener("change", Bridge.fn.bind(this, $asm.$.JSLib.Mobile.UIBase.f2));
        },
        Execute: function () {

        },
        WriteLiteral: function (content) {
            this.contentBuilder.append(content);
        },
        Write: function (content) {
            this.contentBuilder.append(content);
        },
        WriteLiteralTo: function (textWriter, content) {
            textWriter.append(content);
        },
        WriteTo: function (textWriter, content) {
            if (content == null) {
                textWriter.append("");
            } else {
                textWriter.append(content);
            }

        },
        GetHtmlContent: function () {
            this.Execute();
            return this.contentBuilder.toString();
        },
        InitialComponent: function () {
        },
        DestoryComponent: function () {
        },
        SetScrollable: function (ele, showScrollBar, vScroll, hScroll, onScrollStart, onScrollMove, onScrollEnd, containerClassName, enablePullDownToRefresh, refreshAction, enableBounce, enableMomentum) {
            if (showScrollBar === void 0) { showScrollBar = false; }
            if (vScroll === void 0) { vScroll = true; }
            if (hScroll === void 0) { hScroll = false; }
            if (onScrollStart === void 0) { onScrollStart = null; }
            if (onScrollMove === void 0) { onScrollMove = null; }
            if (onScrollEnd === void 0) { onScrollEnd = null; }
            if (containerClassName === void 0) { containerClassName = ""; }
            if (enablePullDownToRefresh === void 0) { enablePullDownToRefresh = false; }
            if (refreshAction === void 0) { refreshAction = null; }
            if (enableBounce === void 0) { enableBounce = true; }
            if (enableMomentum === void 0) { enableMomentum = true; }
            var container = new JSLib.IScrollWraper.IScrollContainer.$ctor1(ele, showScrollBar, vScroll, hScroll, onScrollStart, onScrollMove, onScrollEnd, containerClassName, enablePullDownToRefresh, refreshAction, enableBounce, enableMomentum);
            this.iscrollContainers.add(container);
            return container;
        },
        SetIscrollList: function (target, pageSize, limitPageCount, enableRefreshData, autoRemoveDom, showScrollBar) {
            if (pageSize === void 0) { pageSize = 20; }
            if (limitPageCount === void 0) { limitPageCount = 3; }
            if (enableRefreshData === void 0) { enableRefreshData = true; }
            if (autoRemoveDom === void 0) { autoRemoveDom = true; }
            if (showScrollBar === void 0) { showScrollBar = true; }
            var container = new JSLib.IScrollWraper.IScrollList(target, pageSize, limitPageCount, enableRefreshData, autoRemoveDom);
            this.iscrollListContainers.add(container);
            container.WrapPullAndRefresh(showScrollBar);
            return container;
        },
        RefreshPageScroll: function () {
            window.setTimeout(Bridge.fn.bind(this, function () {
                var $t, $t1;
                if (this.iscrollContainers != null) {
                    $t = Bridge.getEnumerator(this.iscrollContainers);
                    while ($t.moveNext()) {
                        var iscrollContainer = $t.getCurrent();
                        iscrollContainer.iscroll.refresh();
                    }
                }
                if (this.iscrollListContainers != null) {
                    $t1 = Bridge.getEnumerator(this.iscrollListContainers);
                    while ($t1.moveNext()) {
                        var iscrollListContainer = $t1.getCurrent();
                        iscrollListContainer.Refresh();
                    }
                }

            }), 300);

        },
        DestoryIscroll: function () {
            var $t, $t1;
            try {
                //销毁IscrollContainer
                $t = Bridge.getEnumerator(this.iscrollContainers);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    if (item != null) {
                        item.Destroy();
                    }
                }
                $t1 = Bridge.getEnumerator(this.iscrollListContainers);
                while ($t1.moveNext()) {
                    var item1 = $t1.getCurrent();
                    if (item1 != null) {
                        item1.Destroy();
                    }
                }

            }
            catch (ex) {
                ex = System.Exception.create(ex);
                ConsoleEx.Dump(System.Exception, ex);
            }

        },
        Destroy: function () {
            this.OnOrientationChange = null;
        },
        Disable: function (isReadOnly) {
            var resultstr = "";
            if (isReadOnly) {
                resultstr = "disabled='disabled'";

            }

            return resultstr;
        },
        DisableAndReadOnly: function (isReadOnly) {
            var resultstr = "";
            if (isReadOnly) {
                resultstr = "readonly='readonly' disabled='disabled'";
            }
            return resultstr;
        },
        BindProperty: function (TSource, TMember, source, propertyLambda) {
            var $t;
            var member = ($t = propertyLambda.body, Bridge.as($t, Bridge.hasValue($t) && ($t.ntype === 23)));
            return System.String.concat("{{", member.member.n, "}}");
        },
        BindTitleAttribute: function (TSource, TMember, source, propertyLambda) {
            var $t;
            var member = ($t = propertyLambda.body, Bridge.as($t, Bridge.hasValue($t) && ($t.ntype === 23)));
            return System.String.format("v-bind:title='{0}'", member.member.n);
        },
        BindVisible: function (TSource, TMember, source, propertyLambda) {
            var $t;
            var member = ($t = propertyLambda.body, Bridge.as($t, Bridge.hasValue($t) && ($t.ntype === 23)));
            return System.String.format("v-if='{0}'", member.member.n);
        }
    });

    Bridge.ns("JSLib.Mobile.UIBase", $asm.$);

    Bridge.apply($asm.$.JSLib.Mobile.UIBase, {
        f1: function () {
            this.OnOrientationChange(Bridge.merge(new JSLib.Mobile.OrientationChangArgs(), {
                OrientationValue: window.orientation
            } ));
        },
        f2: function (event) {
            if (!Bridge.staticEquals(this.OnOrientationChange, null)) {
                window.setTimeout(Bridge.fn.bind(this, $asm.$.JSLib.Mobile.UIBase.f1), 200);
            }
        }
    });

    Bridge.define("JSLib.Controller.RazorTemplate", {
        contentBuilder: null,
        config: {
            init: function () {
                this.contentBuilder = new System.Text.StringBuilder();
            }
        },
        Execute: function () {

        },
        WriteLiteral: function (content) {
            this.contentBuilder.append(content);
        },
        Write: function (content) {
            this.contentBuilder.append(content);
        },
        WriteLiteralTo: function (textWriter, content) {
            textWriter.append(content);
        },
        WriteTo: function (textWriter, content) {
            if (content == null) {
                textWriter.append("");
            } else {
                textWriter.append(content);
            }

        },
        InitialComponent: function () {
        },
        DestoryComponent: function () {
        }
    });

    Bridge.define("JSLib.Controller.TabPanel", {
        statics: {
            RegisterTabPanel: function (pnlTabHeads) {
                pnlTabHeads.on("click", ">div", function (event) {
                    var target = $(event.currentTarget);
                    target.addClass("active").show().siblings().removeClass("active");

                    var pnlTabContents = pnlTabHeads.next();
                    $(pnlTabContents.children()[target.index()]).addClass("active").show().siblings().removeClass("active").hide();
                });
                pnlTabHeads.children().first().click();
            }
        }
    });

    Bridge.define("JSLib.Data.BindData", {
        Data: null,
        ContainerId: null,
        config: {
            init: function () {
                this.Data = new (System.Collections.Generic.List$1(JSLib.Data.BindDataItem))();
            }
        }
    });

    Bridge.define("JSLib.Data.BindDataItem", {
        bindId: null,
        data: null
    });

    Bridge.define("JSLib.Data.DataBindHelper", {
        statics: {
            bindDatas: null,
            config: {
                init: function () {
                    this.bindDatas = new (System.Collections.Generic.List$1(JSLib.Data.BindData))();
                }
            },
            Bind: function (target, containerId) {
                var bindId = System.Guid.newGuid().toString();

                var bindData = System.Linq.Enumerable.from(JSLib.Data.DataBindHelper.bindDatas).firstOrDefault(function (n) {
                        return Bridge.referenceEquals(n.ContainerId, containerId);
                    }, null);
                if (bindData == null) {
                    bindData = Bridge.merge(new JSLib.Data.BindData(), {
                        ContainerId: containerId
                    } );
                    JSLib.Data.DataBindHelper.bindDatas.add(bindData);
                }
                bindData.Data.add(Bridge.merge(new JSLib.Data.BindDataItem(), {
                    bindId: bindId,
                    data: target
                } ));
                if (target != null) {
                    return System.String.format("data-c-bindid='{0}' data-c-type='{1}'", bindId, Bridge.Reflection.getTypeFullName(Bridge.getType(target)));
                } else {
                    console.log("绑定值为空");
                    return "";
                }
            },
            RemoveBindData: function (containerId) {
                var bindData = System.Linq.Enumerable.from(JSLib.Data.DataBindHelper.bindDatas).firstOrDefault(function (n) {
                        return Bridge.referenceEquals(n.ContainerId, containerId);
                    }, null);
                if (bindData != null) {
                    JSLib.Data.DataBindHelper.bindDatas.remove(bindData);
                }
            }
        }
    });

    Bridge.define("JSLib.Widget.ViewPager.FixedLengthDictionary$2", function (TKey, TValue) { return {
        inherits: [System.Collections.Generic.Dictionary$2(TKey,TValue)],
        MaxCount: 3,
        keyList: null,
        config: {
            events: {
                BeforeItemRemove: null,
                OnItemAdd: null
            },
            init: function () {
                this.keyList = new (System.Collections.Generic.List$1(TKey))();
            }
        },
        ctor: function (maxCount) {
            if (maxCount === void 0) { maxCount = 5; }

            this.$initialize();
            System.Collections.Generic.Dictionary$2(TKey,TValue).ctor.call(this);
            this.MaxCount = maxCount;
        },
        AddItem: function (key, value, isTail) {
            if (isTail === void 0) { isTail = true; }
            if (this.containsKey(key) || value == null) {
                return false;
            }
            if (this.getCount() >= ((this.MaxCount + 1) | 0)) {
                if (isTail) {
                    var removeKey = System.Linq.Enumerable.from(this.keyList).first();
                    this.keyList.remove(removeKey);
                    if (!Bridge.staticEquals(this.BeforeItemRemove, null)) {
                        this.BeforeItemRemove(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedLengthDictionary$2.ItemArgs(TKey,TValue))(), {
                            key: key,
                            value: this.get(removeKey),
                            IsTail: false
                        } ));
                    }
                    this.remove(removeKey);
                } else {
                    var removeKey1 = System.Linq.Enumerable.from(this.keyList).last();
                    this.keyList.remove(removeKey1);
                    if (!Bridge.staticEquals(this.BeforeItemRemove, null)) {
                        this.BeforeItemRemove(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedLengthDictionary$2.ItemArgs(TKey,TValue))(), {
                            key: key,
                            value: this.get(removeKey1),
                            IsTail: true
                        } ));
                    }
                    this.remove(removeKey1);
                }
            }


            if (isTail) {
                this.keyList.add(key);
            } else {
                this.keyList.insert(0, key);
            }
            this.set(key, value);
            if (!Bridge.staticEquals(this.OnItemAdd, null)) {
                this.OnItemAdd(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedLengthDictionary$2.ItemArgs(TKey,TValue))(), {
                    key: key,
                    value: value,
                    IsTail: isTail
                } ));
            }
            return true;
        }
    }; });

    Bridge.define("JSLib.Data.GestureDirection", {
        $kind: "enum",
        statics: {
            LeftToRight: -1,
            RightToLeft: 1
        }
    });

    Bridge.define("JSLib.DesktopComponent.DataGrid", {
        option: null,
        ctor: function (option) {
            this.$initialize();
            this.option = option;

            this.LoadData();
            option.Pager.on("page", Bridge.fn.bind(this, function () {
                var pageIndex = (option.Pager.find("li.active").data("lp") - 1) | 0;
                this.LoadData(pageIndex);
            }));


            option.PnlTableContent.on("mouseout", "tr", $asm.$.JSLib.DesktopComponent.DataGrid.f1);

            option.PnlTableContent.on("mouseover", "tr", $asm.$.JSLib.DesktopComponent.DataGrid.f2);
            option.BtnCheckAll != null ? option.BtnCheckAll.click(function (event) {
                option.PnlTableContent.find("input[type=checkbox]").each($asm.$.JSLib.DesktopComponent.DataGrid.f3);






            }) : null;

            option.PnlTableContent.on("click", "tr", $asm.$.JSLib.DesktopComponent.DataGrid.f4);
            option.BtnReversAll != null ? option.BtnReversAll.click(function (event) {
                option.PnlTableContent.find("input[type=checkbox]").each($asm.$.JSLib.DesktopComponent.DataGrid.f5);






            }) : null;
        },
        LoadData: function (pageIndex) {
            var $step = 0,
                $task1, 
                $taskResult1, 
                $jumpFromFinally, 
                result, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    for (;;) {
                        $step = System.Array.min([0,1], $step);
                        switch ($step) {
                            case 0: {
                                if (pageIndex === void 0) { pageIndex = 0; }
                                    $task1 = this.option.LoadGridData(pageIndex, this.option.PageSize);
                                    $step = 1;
                                    $task1.continueWith($asyncBody, true);
                                    return;
                            }
                            case 1: {
                                $taskResult1 = $task1.getAwaitedResult();
                                result = $taskResult1;
                                    if (result != null) {
                                        this.option.PnlTableContent.html(result.TableBody);
                                        this.CreatePagination(result.TotalRecords, this.option.PageSize);
                                    } else {
                                        this.option.Pager.data("settings").page = 0;
                                        this.CreatePagination(0, this.option.PageSize);

                                    }
                                return;
                            }
                            default: {
                                return;
                            }
                        }
                    }
                }, arguments);

            $asyncBody();
        },
        CreatePagination: function (totalRecords, pageSize) {
            var pages;
            if (totalRecords % pageSize === 0) {
                pages = (Bridge.Int.div(totalRecords, pageSize)) | 0;
            } else {
                pages = (((Bridge.Int.div(totalRecords, pageSize)) | 0) + 1) | 0;
            }
            if (pages === 0) {
                pages = 1;
            }
            this.option.Pager.bootpag({ total: pages, maxVisible: 15, first: "首页", last: "尾页", firstLastUse: true });
            this.option.lblSummary != null ? this.option.lblSummary.text(System.String.format("合计{0}条数据", totalRecords)) : null;
        },
        Reload: function () {
            var setting = this.option.Pager.data("settings");
            if (setting != null) {
                setting.page = 1;
            }
            this.LoadData();
        },
        Refresh: function () {
            var setting = this.option.Pager.data("settings");
            if (setting == null) {
                return;
            }
            var pageIndex = setting.page - 1;
            this.LoadData(pageIndex);
        }
    });

    Bridge.ns("JSLib.DesktopComponent.DataGrid", $asm.$);

    Bridge.apply($asm.$.JSLib.DesktopComponent.DataGrid, {
        f1: function (event) {
            $(event.currentTarget).removeClass("trOver");
        },
        f2: function (event) {
            $(event.currentTarget).addClass("trOver");
        },
        f3: function (index, element) {
            element.checked = true;
        },
        f4: function (event) {
            if ($(event.target).is("[data-check-exclude]")) {
                return;
            }
            $(event.currentTarget).find("input[type=checkbox]").click();
        },
        f5: function (index, element) {
            element.checked = !element.checked;
        }
    });

    Bridge.define("JSLib.DesktopComponent.DataGridOption", {
        Pager: null,
        PageSize: 0,
        PnlTableContent: null,
        lblSummary: null,
        LoadGridData: null,
        BtnCheckAll: null,
        BtnReversAll: null
    });

    Bridge.define("JSLib.DesktopComponent.LoadGridDataResult", {
        TableBody: null,
        TotalRecords: 0
    });

    Bridge.define("JSLib.Device", {
        statics: {
            DialNo: function (phoneNo) {
                //Window.Location.Href = "tel:" + No;
                var anchor = document.createElement("a");
                anchor.setAttribute("href", System.String.concat("tel:", phoneNo));
                anchor.setAttribute("target", "_self");

                var dispatch = document.createEvent("HTMLEvents");
                dispatch.initEvent("click", true, true);
                anchor.dispatchEvent(dispatch);
            },
            ChooseDate: function (curDate) {
                var datePicker = document.createElement("input");
                datePicker.type = "date";
                if (System.Nullable.hasValue(curDate)) {
                    datePicker.value = Bridge.Date.format(System.Nullable.getValue(curDate), "yyyy-MM-dd");
                }

                var dispatch = document.createEvent("HTMLEvents");
                dispatch.initEvent("click", true, true);
                datePicker.dispatchEvent(dispatch);

                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                datePicker.onchange = function () {
                    tsk.setResult(datePicker.valueAsDate);
                };
                return tsk.task;
            }
        }
    });

    Bridge.define("JSLib.ElectronEx.ProcessHelper", {
        statics: {
            getCurrentEncoding: function () {
                if (Bridge.referenceEquals(window.navigator.platform, "MacIntel")) {
                    return "UTF8";
                }
                return "GBK";
            },
            Run: function (commandName, args, showLoading, page) {
                if (showLoading === void 0) { showLoading = true; }
                if (page === void 0) { page = null; }
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                window.setTimeout(function () {
                    var $step = 0,
                        $task1, 
                        $taskResult1, 
                        $task2, 
                        $jumpFromFinally, 
                        loadingDialog, 
                        executeCommand, 
                        $asyncBody = Bridge.fn.bind(this, function () {
                            for (;;) {
                                $step = System.Array.min([0,1,2,3,4], $step);
                                switch ($step) {
                                    case 0: {
                                        loadingDialog = null;
                                            if (page != null && showLoading) {
                                                $step = 1;
                                                continue;
                                            } 
                                            $step = 4;
                                            continue;
                                    }
                                    case 1: {
                                        $task1 = page.ShowLoading();
                                            $step = 2;
                                            $task1.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 2: {
                                        $taskResult1 = $task1.getAwaitedResult();
                                        loadingDialog = $taskResult1;
                                            $task2 = System.Threading.Tasks.Task.delay(2000);
                                            $step = 3;
                                            $task2.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 3: {
                                        $task2.getAwaitedResult();
                                        $step = 4;
                                        continue;
                                    }
                                    case 4: {
                                        executeCommand = System.String.format("{0} {1}", commandName, ObjExtension.JoinWith(args, " "));
                                            if (args != null) {
                                                args = System.Linq.Enumerable.from(args).select($asm.$.JSLib.ElectronEx.ProcessHelper.f1).toArray();
                                            }

                                            window.setTimeout(function () {
                                                var process = JSLib.ElectronEx.ProcessHelper.SpawnProcess(commandName, args);
                                                var pr = Bridge.merge(new JSLib.ElectronEx.ProcessResult(), {
                                                    Command: executeCommand,
                                                    ExitCode: process.status,
                                                    OutPutMessage: ObjExtension.BufferToString(process.stdout),
                                                    ErrorMessage: ObjExtension.BufferToString(process.stderr)
                                                } );
                                                loadingDialog != null ? loadingDialog.Destroy() : null;
                                                tsk.setResult(pr);
                                            });
                                        return;
                                    }
                                    default: {
                                        return;
                                    }
                                }
                            }
                        }, arguments);

                    $asyncBody();
                });

                return tsk.task;
            },
            SpawnProcess: function (command, args) {
                console.info(System.String.format("执行命令: {0} {1}", command, ObjExtension.JoinWith(args, " ")));
                var process = require('child_process').spawnSync(command, ObjExtension.EnsureNotNull(String, args), {  });
                return process;
            }
        }
    });

    Bridge.ns("JSLib.ElectronEx.ProcessHelper", $asm.$);

    Bridge.apply($asm.$.JSLib.ElectronEx.ProcessHelper, {
        f1: function (n) {
            if (System.String.startsWith(n, "\"") && System.String.endsWith(n, "\"")) {
                n = n.substr(1, ((n.length - 2) | 0));
            }
            return n;
        }
    });

    Bridge.define("JSLib.ElectronEx.ProcessResult", {
        Command: null,
        SuccessMessage: null,
        ErrorMessage: null,
        OutPutMessage: "",
        ExitCode: 0
    });

    Bridge.define("JSLib.Extension.BBQ");

    Bridge.define("JSLib.Extension.FileSizeExtension", {
        statics: {
            GetMB: function (target) {
                var data = (target / 1024 / 1024);
                return data.toFixed(1);
            }
        }
    });

    Bridge.define("JSLib.Extension.ImageExtension", {
        statics: {
            GetImageUrlBase64Data: function (imageUrl, onComplete) {
                //var image = Document.CreateElement("img").As<ImageElement>();
                //image.AddEventListener("load", delegate(Event @event1)
                //    {
                //        var mycanvasElement = (CanvasElement)Document.CreateElement("canvas");
                //        mycanvasElement.Width = image.Width;
                //        mycanvasElement.Height = image.Height;
                //        ((CanvasRenderingContext2D)mycanvasElement.GetContext("2d")).DrawImage(image, 0, 0, image.Width, image.Height);
                //        var resultUrl = (string)mycanvasElement.GetDataUrl("image/png");
                //        image = null;
                //        onComplete(resultUrl);
                //    }, false);
                //image.Src = imageUrl;
            }
        }
    });

    Bridge.define("JSLib.Extension.jQueryEx", {
        statics: {
            SetEnable: function (target, isEnable) {
                if (isEnable) {
                    target.removeAttr("disabled");
                } else {
                    target.attr("disabled", "disabled");
                }
            },
            SetReadonly: function (target, isReadOnly) {
                if (!isReadOnly) {
                    target.removeAttr("readonly");
                } else {
                    target.attr("readonly", "readonly");
                }
            },
            IsEnable: function (target) {
                return System.String.isNullOrEmpty(target.attr("disabled"));
            },
            SetCheckState: function (target, isChecked) {
                if (isChecked) {
                    target.attr("checked", "checked");
                } else {
                    target.removeAttr("checked");
                }
            },
            IsChecked: function (target) {
                if (target.length < 0) {
                    return false;
                }
                return target.get(0).checked;
            },
            SetVisible: function (target, isVisible) {
                return isVisible ? target.show() : target.hide();
            },
            GetSelectedText: function (target) {
                return target.find(":checked").text();
            },
            GetSelectedOption: function (target) {
                return target.find(":checked");
            },
            IsVisible: function (target) {
                return target.is(":visible");
            },
            ParentUntil: function (target, selector) {
                var temp = target.parent();
                while (temp.length > 0 && !temp.is(selector)) {
                    temp = temp.parent();
                }
                return temp;
            },
            ShowAsBox: function (target) {
                return target.css("display", "-webkit-box");
            },
            Scrollable: function (target) {
                var wraper = target.wrapInner("<div  />").children().get(0);
                var iscroll = new iScroll(wraper);
                return iscroll;
            },
            TotalHeight: function (target) {
                var result = 0;

                var lastMarginBottom = 0;
                target.each(function (index, element) {
                    var targetobject = $(element);
                    //元素高度
                    if (JSLib.JSLibConfig.IsUseZepto) {
                        result = (result + (targetobject.height())) | 0;
                    } else {
                        result = (result + (targetobject.outerHeight())) | 0;
                    }

                    //marginTop
                    var marginTop = JSLib.Extension.jQueryEx.MarginTop(targetobject);
                    result = (result + (Math.max(lastMarginBottom, marginTop))) | 0;

                    //marginBottom
                    lastMarginBottom = JSLib.Extension.jQueryEx.MarginBottom(targetobject);
                });
                //最后一个元素的MarginBottom;
                result = (result + lastMarginBottom) | 0;

                return result;
            },
            MarginTop: function (target) {
                if (target.length < 0) {
                    return 0;
                }
                var marginTop = CssEx.PxToInt(window.getComputedStyle(target.get(0)).marginTop);
                return marginTop;
            },
            MarginBottom: function (target) {
                if (target.length < 0) {
                    return 0;
                }
                var marginTop = CssEx.PxToInt(window.getComputedStyle(target.get(0)).marginBottom);
                return marginTop;
            },
            BackgroundImage: function (target, imageUrl) {
                target.each(function (index, element) {
                    element.style.backgroundImage = System.String.format("url({0})", imageUrl);
                });
                return target;
            },
            GetBackgroundImage: function (target) {
                var url = target.get(0).style.backgroundImage;
                if (System.String.isNullOrEmpty(url)) {
                    return "";
                }
                var beginIndex = (System.String.indexOf(url, "url(") + 4) | 0;
                var endIndex = System.String.indexOf(url, ")");
                return url.substr(beginIndex, ((endIndex - beginIndex) | 0));
            },
            TojQuery: function (target) {
                return $(target);
            },
            TojQuery$1: function (target) {
                return $(target.toString());
            },
            TranslateX: function (target, x) {
                return target.css("transform", System.String.format("translateX({0}px)", x));
            },
            TranslateY: function (target, y) {
                return target.css("transform", System.String.format("translateY({0}px)", y));
            },
            MinusHalfHeightMarginTop: function (target) {
                if (target != null && target.length > 0) {
                    target.each($asm.$.JSLib.Extension.jQueryEx.f1);
                }
                return target;
            },
            IsAll: function (target, predicateFunc) {
                var totalCount = target.length;
                var actualCount = 0;
                target.each(function (index, element) {
                    if (predicateFunc(element)) {
                        actualCount = (actualCount + 1) | 0;
                    }
                });
                return totalCount === actualCount;
            },
            IsOverLapRec: function (target, dest) {
                var rect = target.get(0).getBoundingClientRect();

                var x1 = rect.left;
                var y1 = rect.top;
                var w1 = rect.width;
                var h1 = rect.height;

                var rect2 = dest.get(0).getBoundingClientRect();
                var x2 = rect2.left;
                var y2 = rect2.top;
                var w2 = rect2.width;
                var h2 = rect2.top;

                var xfitable = ((x2 + w2 >= x1) && (x2 <= x1 + w1));
                var yfitable = (y2 + h2 >= y1 && y2 <= y1 + h1);
                return xfitable && yfitable;
            },
            CenterOver: function (target, dest) {
                var pos = dest.offset();
                var containerRec = dest.get(0).getBoundingClientRect();
                var targetRec = target.get(0).getBoundingClientRect();
                pos.left = (pos.left + (((Bridge.Int.div((containerRec.width - targetRec.width), 2)) | 0))) | 0;
                pos.top = (pos.top + (((Bridge.Int.div((containerRec.height - targetRec.height), 2)) | 0))) | 0;
                target.offset(pos);
                return pos;
            },
            Top: function (target, value) {
                target.each(function (index, element) {
                    element.style.top = value+'px';
                });
                return target;
            },
            Right: function (target, value) {
                target.each(function (index, element) {
                    element.style.right = value+'px';
                });
                return target;
            },
            Bottom: function (target, value) {
                target.each(function (index, element) {
                    element.style.bottom = value+'px';
                });
                return target;
            },
            Left: function (target, value) {
                target.each(function (index, element) {
                    element.style.left = value+'px';
                });
                return target;
            },
            SlidIn: function (target, slideInClass, delay) {
                var $step = 0,
                    $task1, 
                    $jumpFromFinally, 
                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                    $returnValue, 
                    $async_e, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        try {
                            for (;;) {
                                $step = System.Array.min([0,1,2,3], $step);
                                switch ($step) {
                                    case 0: {
                                        if (delay === void 0) { delay = true; }

                                            //return target.AddClass("SlideInPage").Animate(new System.Collections.JsDictionary("left", "0"), EffectDuration.Fast, EffectEasing.Swing, delegate
                                            //{
                                            //    target.RemoveClass("SlideInPage");
                                            //});
                                            target.addClass(slideInClass);
                                            if (delay) {
                                                $step = 1;
                                                continue;
                                            } 
                                            $step = 3;
                                            continue;
                                    }
                                    case 1: {
                                        $task1 = System.Threading.Tasks.Task.delay(500);
                                            $step = 2;
                                            $task1.continueWith($asyncBody);
                                            return;
                                    }
                                    case 2: {
                                        $task1.getAwaitedResult();
                                        $step = 3;
                                        continue;
                                    }
                                    case 3: {
                                        target.removeClass(slideInClass);
                                        $tcs.setResult(null);
                                        return;
                                    }
                                    default: {
                                        $tcs.setResult(null);
                                        return;
                                    }
                                }
                            }
                        } catch($async_e1) {
                            $async_e = System.Exception.create($async_e1);
                            $tcs.setException($async_e);
                        }
                    }, arguments);

                $asyncBody();
                return $tcs.task;
            },
            SlidOutTask: function (target, slideInReverseClass, delay) {
                var $step = 0,
                    $task1, 
                    $jumpFromFinally, 
                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                    $returnValue, 
                    $async_e, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        try {
                            for (;;) {
                                $step = System.Array.min([0,1,2,3], $step);
                                switch ($step) {
                                    case 0: {
                                        if (delay === void 0) { delay = true; }


                                            target.addClass(slideInReverseClass);
                                            if (delay) {
                                                $step = 1;
                                                continue;
                                            } 
                                            $step = 3;
                                            continue;
                                    }
                                    case 1: {
                                        $task1 = System.Threading.Tasks.Task.delay(500);
                                            $step = 2;
                                            $task1.continueWith($asyncBody);
                                            return;
                                    }
                                    case 2: {
                                        $task1.getAwaitedResult();
                                        $step = 3;
                                        continue;
                                    }
                                    case 3: {
                                        target.hide();
                                            //target.RemoveClass(slideInReverseClass);
                                        $tcs.setResult(null);
                                        return;
                                    }
                                    default: {
                                        $tcs.setResult(null);
                                        return;
                                    }
                                }
                            }
                        } catch($async_e1) {
                            $async_e = System.Exception.create($async_e1);
                            $tcs.setException($async_e);
                        }
                    }, arguments);

                $asyncBody();
                return $tcs.task;
            },
            GetEnumValue: function (T, target, nullValue) {
                if (nullValue === void 0) { nullValue = -1; }
                var value = CoreEx.ToInt(target.val());
                if (value === nullValue) {
                    return Bridge.getDefaultValue(T);
                } else {
                    return value;
                }
            },
            IsValidateForm: function (target) {
                var $t;
                var inputs = target.find("input[required]").toArray();
                $t = Bridge.getEnumerator(inputs);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    var targetEle = $(item);
                    if (System.String.isNullOrEmpty(targetEle.val())) {
                        targetEle.focus();
                        return false;
                    }
                }
                return true;
            }
        }
    });

    Bridge.ns("JSLib.Extension.jQueryEx", $asm.$);

    Bridge.apply($asm.$.JSLib.Extension.jQueryEx, {
        f1: function (index, element) {
            element.style.marginTop = (((Bridge.Int.div(((-$(element).outerHeight()) | 0), 2)) | 0))+'px';
        }
    });

    Bridge.define("JSLib.Extension.md5.MD5", {
        statics: {
            GetMd5: function (source) {
                return hex_md5(source).toUpperCase();
            }
        }
    });

    Bridge.define("JSLib.Extension.MergeMode", {
        $kind: "enum"
    });

    Bridge.define("JSLib.Extension.StyleSheetEx", {
        statics: {
            AddCssRule: function (cssRule) {
                var cssElement = $(System.String.format("<style>{0}</style>", cssRule));
                $(document.body).append(cssElement);
            }
        }
    });

    Bridge.define("JSLib.Extension.TouchDirection", {
        $kind: "enum",
        statics: {
            None: 0,
            LeftToRight: 1,
            RightToLeft: 2,
            UpToDown: 4,
            DownToUp: 8
        },
        $flags: true
    });

    Bridge.define("JSLib.Extension.TouchHandler", {
        mouseContainer: null,
        _currentX: 0,
        _currentY: 0,
        _preX: 0,
        _preY: 0,
        _totalDeltaX: 0,
        _totalDeltaY: 0,
        canRecord: false,
        timeIDList: null,
        waitTime: 100,
        config: {
            events: {
                OnFling: null,
                OnComplete: null
            },
            init: function () {
                this.timeIDList = new (System.Collections.Generic.List$1(System.Int32))();
            }
        },
        ctor: function (mouseContainer) {
            this.$initialize();
            this.mouseContainer = mouseContainer;
        },
        getcurrentX: function () {
            return this._currentX;
        },
        setcurrentX: function (value) {
            this._preX = this._currentX;
            this._currentX = value;
        },
        getcurrentY: function () {
            return this._currentY;
        },
        setcurrentY: function (value) {
            this._preY = this._currentY;
            this._currentY = value;
        },
        ToString: function () {
            return System.String.format("CurrentX: {0},CurrentY:{1}", this.getcurrentX(), this.getcurrentY());
        },
        BeginListen: function () {
            this.mouseContainer.on("touchstart", Bridge.fn.bind(this, this.ontouchStart));

            this.mouseContainer.on("touchmove", Bridge.fn.bind(this, this.ontouchMove));
            this.mouseContainer.on("touchend", Bridge.fn.bind(this, this.ontouchEnd));
        },
        ontouchEnd: function (event) {

            var touchInfo = Bridge.cast(event.originalEvent, TouchEvent).changedTouches[0];
            this.setcurrentX(touchInfo.screenX);
            this.setcurrentY(touchInfo.screenY);
            Bridge.Linq.Enumerable.from(this.timeIDList).forEach($asm.$.JSLib.Extension.TouchHandler.f1);

            var deltaX = this.getcurrentX() - this._preX;
            var deltaY = this.getcurrentY() - this._preY;
            this._totalDeltaX += deltaX;
            this._totalDeltaY += deltaY;
            var touchHandlerArgs = Bridge.merge(new JSLib.Extension.TouchHandlerArgs(), {
                currentX: this._currentX,
                currentY: this._currentY,
                deltaX: deltaX,
                deltaY: deltaY,
                TotalDeltaX: this._totalDeltaX,
                TotalDeltaY: this._totalDeltaY,
                IsComplete: true
            } );
            !Bridge.staticEquals(this.OnComplete, null) ? this.OnComplete(this, touchHandlerArgs) : null;
            this._totalDeltaX = 0;
            this._totalDeltaY = 0;
        },
        ontouchMove: function (event) {
            if (this.canRecord) {
                var touchInfo = Bridge.cast(event.originalEvent, TouchEvent).touches[0];
                this.setcurrentX(touchInfo.screenX);
                this.setcurrentY(touchInfo.screenY);
                this.canRecord = false;
                if (!Bridge.staticEquals(this.OnFling, null)) {
                    var deltaX = this.getcurrentX() - this._preX;
                    var deltaY = this.getcurrentY() - this._preY;
                    this._totalDeltaX += deltaX;
                    this._totalDeltaY += deltaY;
                    this.OnFling(this, Bridge.merge(new JSLib.Extension.TouchHandlerArgs(), {
                        currentX: this._currentX,
                        currentY: this._currentY,
                        deltaX: deltaX,
                        deltaY: deltaY,
                        TotalDeltaX: this._totalDeltaX,
                        TotalDeltaY: this._totalDeltaY
                    } ));
                }
            }
        },
        ontouchStart: function (event) {
            var touchInfo = Bridge.cast(event.originalEvent, TouchEvent).touches[0];
            this.setcurrentX(touchInfo.screenX);
            this.setcurrentY(touchInfo.screenY);
            this.timeIDList.add(window.setInterval(Bridge.fn.bind(this, $asm.$.JSLib.Extension.TouchHandler.f2), this.waitTime));
            event.preventDefault();
        },
        StopListen: function () {
            this.mouseContainer.off("touchstart", Bridge.fn.bind(this, this.ontouchStart));

            this.mouseContainer.off("touchmove", Bridge.fn.bind(this, this.ontouchMove));
            this.mouseContainer.off("touchend", Bridge.fn.bind(this, this.ontouchEnd));
        }
    });

    Bridge.ns("JSLib.Extension.TouchHandler", $asm.$);

    Bridge.apply($asm.$.JSLib.Extension.TouchHandler, {
        f1: function (i) {
            window.clearInterval(i);
        },
        f2: function () {
            this.canRecord = true;
        }
    });

    Bridge.define("JSLib.Extension.TouchHandlerArgs", {
        currentX: 0,
        currentY: 0,
        deltaX: 0,
        deltaY: 0,
        TotalDeltaX: 0,
        TotalDeltaY: 0,
        IsComplete: false,
        getDirection: function () {
            var dir = JSLib.Extension.TouchDirection.None;
            if (this.TotalDeltaX < 0) {
                dir = dir | JSLib.Extension.TouchDirection.RightToLeft;
            } else if (this.TotalDeltaX > 0) {
                dir = dir | JSLib.Extension.TouchDirection.LeftToRight;
            }

            if (this.TotalDeltaY < 0) {
                dir = dir | JSLib.Extension.TouchDirection.DownToUp;
            } else if (this.TotalDeltaY > 0) {
                dir = dir | JSLib.Extension.TouchDirection.UpToDown;
            }
            return dir;
        },
        getIsRightToLeft: function () {
            return (this.getDirection() & JSLib.Extension.TouchDirection.RightToLeft) === JSLib.Extension.TouchDirection.RightToLeft;
        },
        getIsLeftToRight: function () {
            return (this.getDirection() & JSLib.Extension.TouchDirection.LeftToRight) === JSLib.Extension.TouchDirection.LeftToRight;
        },
        getIsUpToDown: function () {
            return (this.getDirection() & JSLib.Extension.TouchDirection.UpToDown) === JSLib.Extension.TouchDirection.UpToDown;
        },
        getIsDownToUp: function () {
            return (this.getDirection() & JSLib.Extension.TouchDirection.DownToUp) === JSLib.Extension.TouchDirection.DownToUp;
        }
    });

    Bridge.define("JSLib.Helper.CookieHelper", {
        statics: {
            createCookie: function (name, value, days) {
                if (days === void 0) { days = 0; }
                var expires = "";
                if (days > 0) {
                    var date = new Date(new Date().valueOf() + Math.round((days) * 864e5));
                    expires = System.String.concat("; expires=", date.toGMTString());
                } else {
                    expires = "";
                }
                document.cookie = System.String.concat(name, "=", value, expires, "; path=/");
            },
            readCookie: function (name) {

                var nameEQ = System.String.concat(name, "=");
                var ca = document.cookie.split(";");
                for (var i = 0; i < ca.length; i = (i + 1) | 0) {
                    var c = ca[i];
                    while (c.charCodeAt(0) === 32) {
                        c = c.substr(1, c.length);
                    }
                    if (System.String.indexOf(c, nameEQ) === 0) {
                        return c.substr(nameEQ.length, c.length);
                    }
                }
                return null;
            },
            eraseCookie: function (name) {
                JSLib.Helper.CookieHelper.createCookie(name, "", -1);
            }
        }
    });

    Bridge.define("JSLib.IScrollWraper.Carousel", {
        _iscroll: null,
        isStart: false,
        titleObject: null,
        targetUl: null,
        autoSwipeIntervalID: 0,
        currentPageIndex: 0,
        pageCount: 0,
        childElementCount: 0,
        config: {
            events: {
                OnItemClick: null
            }
        },
        ctor: function (dataList, elementWidth, useIndicator, autoSwipe, carouselWraperClass) {
            if (elementWidth === void 0) { elementWidth = 300; }
            if (useIndicator === void 0) { useIndicator = true; }
            if (autoSwipe === void 0) { autoSwipe = false; }
            if (carouselWraperClass === void 0) { carouselWraperClass = ""; }

            this.$initialize();
            this.targetUl = $(dataList);
            this.childElementCount = this.targetUl.children().length;
            var wrapper = this.targetUl.wrapAll(System.String.format("<div class='c-carousel-warper {0}'/>", carouselWraperClass)).wrapAll("<div class='c-carousel'/>").parent().parent();


            var SetWidth = Bridge.fn.bind(this, function () {
                var $step = 0,
                    $task1, 
                    $jumpFromFinally, 
                    maxCount, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3,4], $step);
                            switch ($step) {
                                case 0: {
                                    maxCount = 10;
                                    $step = 1;
                                    continue;
                                }
                                case 1: {
                                    if ( elementWidth === 0 && maxCount >= 0 ) {
                                            $step = 2;
                                            continue;
                                        } 
                                        $step = 4;
                                        continue;
                                }
                                case 2: {
                                    $task1 = System.Threading.Tasks.Task.delay(100);
                                        $step = 3;
                                        $task1.continueWith($asyncBody, true);
                                        return;
                                }
                                case 3: {
                                    $task1.getAwaitedResult();
                                    elementWidth = dataList.getBoundingClientRect().width;
                                        if (elementWidth > 0) {
                                            $step = 4;
                                            continue;
                                        }
                                        maxCount = (maxCount - 1) | 0;

                                        $step = 1;
                                        continue;
                                }
                                case 4: {
                                    wrapper.width(elementWidth);
                                        this.targetUl.parent().width(((elementWidth * this.childElementCount) | 0));
                                        this.targetUl.children().each(function (index, element) {
                                            $(element).width(elementWidth);
                                            //.Height(elementHeight);
                                        });
                                    return;
                                }
                                default: {
                                    return;
                                }
                            }
                        }
                    }, arguments);

                $asyncBody();
            });
            SetWidth();
            this.targetUl.addClass("c-carousel-dataList");
            this.pageCount = this.targetUl.children().length;

            var indicator = null;
            var carouselIndicatorList = null;
            if (useIndicator) {
                var sb = new System.Text.StringBuilder();
                sb.append("<div class='c-carousel-footer'> ");
                //添加标题
                sb.append("<span class='c-carousel-title'></span>");
                //添加指示器
                sb.append("<ul class='c-carousel-indicator' >");
                for (var i = 0; i < this.childElementCount; i = (i + 1) | 0) {
                    sb.append(System.String.format("<li > </li>", null));
                }
                sb.append("</ul>");

                sb.append("</div>");
                indicator = $(sb.toString());
                carouselIndicatorList = indicator.find("ul");
                carouselIndicatorList.children().first().addClass("active");
                this.titleObject = indicator.find("span");
                wrapper.append(indicator);
                var fisrtchild = this.targetUl.children().first();
                if (fisrtchild != null) {
                    var title = fisrtchild.attr("data-title");
                    this.titleObject.text(title);
                }
            }


            var iscrollOption = { snap: true, momentum: false, hScrollbar: false, vScrollbar: false, bounceLock: true, hScroll: true };
            iscrollOption.onScrollEnd = Bridge.fn.bind(this, function () {
                if (indicator != null) {
                    this.onScrollEnd(carouselIndicatorList);
                }
            });
            iscrollOption.onScrollStart = $asm.$.JSLib.IScrollWraper.Carousel.f1;
            this._iscroll = new iScroll(wrapper.get(0), iscrollOption);


            window.setTimeout(Bridge.fn.bind(this, $asm.$.JSLib.IScrollWraper.Carousel.f2), 500);


            if (autoSwipe && this.childElementCount > 1) {
                this.currentPageIndex = 0;
                this.autoSwipeIntervalID = window.setInterval(Bridge.fn.bind(this, function () {
                    if (this._iscroll.scrollerW > 0) {
                        this.currentPageIndex = (this._iscroll.currPageX + 1) | 0;
                        if (this.currentPageIndex === this.pageCount) {
                            this.currentPageIndex = 0;
                        }
                        this._iscroll.scrollToPage(this.currentPageIndex, 0, 500);
                        this.onScrollEnd(carouselIndicatorList);
                    }
                }), 3000);
            }
        },
        onScrollEnd: function (carouselIndicatorList) {
            carouselIndicatorList.children("li.active").removeClass("active");
            carouselIndicatorList.children(System.String.format("li:nth-child({0})", ((this._iscroll.currPageX + 1) | 0))).addClass("active");


            var currentULLi = this.targetUl.children(System.String.format("li:nth-child({0})", ((this._iscroll.currPageX + 1) | 0)));
            var title = currentULLi.attr("data-title");
            if (!System.String.isNullOrEmpty(title)) {
                this.titleObject.text(title);
            }
        },
        Dispose: function () {
            if (this.autoSwipeIntervalID !== 0) {
                window.clearInterval(this.autoSwipeIntervalID);
            }
            if (this._iscroll != null) {
                this._iscroll.destroy();
            }

        },
        GotoPage: function (pageIndex) {

            this._iscroll.scrollToPage(pageIndex, 0, 500);
        }
    });

    Bridge.ns("JSLib.IScrollWraper.Carousel", $asm.$);

    Bridge.apply($asm.$.JSLib.IScrollWraper.Carousel, {
        f1: function () {
            //if (@event != null)
            //{
            //    @event.StopPropagation();
            //    @event.PreventDefault();
            //}

        },
        f2: function () {
            if (this._iscroll != null) {
                this._iscroll.refresh();
            }
        }
    });

    Bridge.define("JSLib.IScrollWraper.CarouselItemArgs", {
        data: null,
        target: null
    });

    Bridge.define("JSLib.IScrollWraper.IScrollContainer", {
        statics: {
            releaseToRefresh: "释放以刷新数据..."
        },
        iscroll: null,
        pullDownEl: null,
        pullDownLabel: null,
        isPullDownBegin: false,
        refreshAction: null,
        enablePullDownToRefresh: false,
        onScrollMove: null,
        onScrollEnd: null,
        $ctor1: function (ele, showScrollBar, vScroll, hScroll, onScrollStart, onScrollMove, onScrollEnd, containerClassName, enablePullDownToRefresh, refreshAction, enableBounce, enableMomentum) {
            if (showScrollBar === void 0) { showScrollBar = false; }
            if (vScroll === void 0) { vScroll = true; }
            if (hScroll === void 0) { hScroll = false; }
            if (onScrollStart === void 0) { onScrollStart = null; }
            if (onScrollMove === void 0) { onScrollMove = null; }
            if (onScrollEnd === void 0) { onScrollEnd = null; }
            if (containerClassName === void 0) { containerClassName = ""; }
            if (enablePullDownToRefresh === void 0) { enablePullDownToRefresh = false; }
            if (refreshAction === void 0) { refreshAction = null; }
            if (enableBounce === void 0) { enableBounce = true; }
            if (enableMomentum === void 0) { enableMomentum = true; }

            this.$initialize();
            this.BuildIscroller(ele, showScrollBar, vScroll, hScroll, function () {
                if (!Bridge.staticEquals(onScrollStart, null)) {
                    onScrollStart();
                }
            }, function () {
                if (!Bridge.staticEquals(onScrollMove, null)) {
                    onScrollMove();
                }
            }, function () {
                if (!Bridge.staticEquals(onScrollEnd, null)) {
                    onScrollEnd();
                }
            }, containerClassName, enablePullDownToRefresh, refreshAction, enableBounce, enableMomentum);
        },
        ctor: function (ele, option, containerClassName) {
            this.$initialize();
            this.BuildIscroller(ele, option.scrollbars, option.vScroll, option.hScroll, option.onScrollStart, option.onScrollMove, option.onScrollEnd, containerClassName, false, null);
        },
        BuildIscroller: function (ele, showScrollBar, vScroll, hScroll, onScrollStart, onScrollMove, onScrollEnd, containerClassName, enablePullDownToRefresh, refreshAction, enableBounce, enableMomentum) {
            if (enableBounce === void 0) { enableBounce = true; }
            if (enableMomentum === void 0) { enableMomentum = true; }
            this.enablePullDownToRefresh = enablePullDownToRefresh;
            this.onScrollMove = onScrollMove;
            this.onScrollEnd = onScrollEnd;
            if (Bridge.referenceEquals(window.getComputedStyle(ele).getwebkitBoxFlex(), "1")) {
                console.info("请设置为可滚动的元素为自然高度,以避免iscroll高度计算错误!", ele);
            }
            var warped = $(ele).wrap("<div></div>").parent().addClass("c-scroll-container").addClass(containerClassName);
            if (enablePullDownToRefresh) {
                warped.before("<div id='pullDown' class='loading'><span class='pullDownIcon'></span><span class='pullDownLabel'>向下拉以刷新...</span></div>");
                this.refreshAction = refreshAction;
                this.pullDownEl = warped.prev();
                this.pullDownLabel = this.pullDownEl.find(".pullDownLabel");

                this.pullDownEl.hide();
            }


            var scrollOptions = { fadeScrollbar: true, hideScrollbar: true, onScrollStart: onScrollStart, onScrollMove: Bridge.fn.bind(this, this.OnScrollMove), onScrollEnd: Bridge.fn.bind(this, this.OnScrollEnd), vScroll: vScroll, hScroll: hScroll };
            if (showScrollBar) {
                scrollOptions.scrollbars = true;
                scrollOptions.fadeScrollbars = true;
            } else {
                scrollOptions.vScrollbar = false;
                scrollOptions.hScrollbar = false;
            }

            scrollOptions.bounce = enableBounce;
            scrollOptions.momentum = enableMomentum;
            this.iscroll = new iScroll(warped[0], scrollOptions);


            window.setTimeout(Bridge.fn.bind(this, $asm.$.JSLib.IScrollWraper.IScrollContainer.f1), 200);
        },
        OnScrollEnd: function () {
            var $step = 0,
                $task1, 
                $task2, 
                $jumpFromFinally, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    for (;;) {
                        $step = System.Array.min([0,1,2,3,4,5,6,7], $step);
                        switch ($step) {
                            case 0: {
                                if (this.enablePullDownToRefresh && this.pullDownEl.hasClass("flip")) {
                                        $step = 1;
                                        continue;
                                    } 
                                    $step = 7;
                                    continue;
                            }
                            case 1: {
                                this.pullDownEl.get(0).className = "loading";
                                    this.pullDownLabel.text("载入中...");

                                    //执行刷新任务
                                    if (!Bridge.staticEquals(this.refreshAction, null)) {
                                        $step = 2;
                                        continue;
                                    } else  {
                                        $step = 4;
                                        continue;
                                    }
                            }
                            case 2: {
                                $task1 = this.refreshAction();
                                    $step = 3;
                                    $task1.continueWith($asyncBody, true);
                                    return;
                            }
                            case 3: {
                                $task1.getAwaitedResult();
                                $step = 6;
                                continue;
                            }
                            case 4: {
                                $task2 = System.Threading.Tasks.Task.delay(3000);
                                    $step = 5;
                                    $task2.continueWith($asyncBody, true);
                                    return;
                            }
                            case 5: {
                                $task2.getAwaitedResult();
                                $step = 6;
                                continue;
                            }
                            case 6: {
                                
                                    this.pullDownEl.removeClass("flip");
                                    this.pullDownEl.hide();
                                $step = 7;
                                continue;
                            }
                            case 7: {
                                !Bridge.staticEquals(this.onScrollEnd, null) ? this.onScrollEnd() : null;

                                    JSLib.Util.IsScrollExtension.CheckRefresh(this.iscroll);
                                return;
                            }
                            default: {
                                return;
                            }
                        }
                    }
                }, arguments);

            $asyncBody();
        },
        OnScrollMove: function () {
            if (this.enablePullDownToRefresh && this.iscroll.distY > 0 && this.iscroll.y > 15 && !this.pullDownEl.hasClass("flip")) {

                this.isPullDownBegin = true;
                this.pullDownEl.show();
                this.pullDownEl.get(0).className = "flip";
                this.pullDownLabel.text(JSLib.IScrollWraper.IScrollContainer.releaseToRefresh);
            }
            !Bridge.staticEquals(this.onScrollMove, null) ? this.onScrollMove() : null;
        },
        Disable: function () {
            this.iscroll != null ? this.iscroll.disable() : null;
        },
        Enable: function () {
            this.iscroll != null ? this.iscroll.enable() : null;
        },
        Destroy: function () {
            this.iscroll != null ? this.iscroll.destroy() : null;
        }
    });

    Bridge.ns("JSLib.IScrollWraper.IScrollContainer", $asm.$);

    Bridge.apply($asm.$.JSLib.IScrollWraper.IScrollContainer, {
        f1: function () {
            this.iscroll.refresh();
        }
    });

    Bridge.define("JSLib.IScrollWraper.IScrollList", {
        statics: {
            releaseToRefresh: "释放以刷新数据..."
        },
        iscroll: null,
        wraper: null,
        targetList: null,
        FromPageIndex: 0,
        ToPageIndex: 0,
        MaxPageIndex: 2147483647,
        PageSize: 20,
        LimitPageCount: 3,
        OnScroll: null,
        pullDownLabel: null,
        pullUpLabel: null,
        EnableRefreshData: false,
        isWarped: false,
        pullDownEl: null,
        pullUpEl: null,
        isPullUpBegin: false,
        isPullDownBegin: false,
        IsLoadingData: false,
        autoRemoveDom: false,
        currentPageIndex: 0,
        config: {
            properties: {
                GetPageData: null
            },
            init: function () {
                this.FromPageIndex = JSLib.Mobile.Application.getPageIndexStart();
                this.ToPageIndex = JSLib.Mobile.Application.getPageIndexStart();
                this.currentPageIndex = JSLib.Mobile.Application.getPageIndexStart();
            }
        },
        ctor: function (target, pageSize, limitPageCount, enableRefreshData, autoRemoveDom) {
            if (pageSize === void 0) { pageSize = 20; }
            if (limitPageCount === void 0) { limitPageCount = 3; }
            if (enableRefreshData === void 0) { enableRefreshData = true; }
            if (autoRemoveDom === void 0) { autoRemoveDom = true; }

            this.$initialize();
            this.autoRemoveDom = autoRemoveDom;
            this.targetList = $(target);
            this.PageSize = pageSize;
            this.LimitPageCount = limitPageCount;
            this.EnableRefreshData = enableRefreshData;
        },
        WrapPullAndRefresh: function (showScrollBar) {
            if (showScrollBar === void 0) { showScrollBar = true; }
            if (this.isWarped) {
                console.error("当前方法已执行!");
                throw new System.Exception("当前方法已执行!");
            }
            this.isWarped = true;
            this.targetList.wrapAll("<div class='c-scroll-container'/>").wrapAll("<div class='c-scroll-warper'/>");
            this.targetList.before("<div id='pullDown' class='loading'><span class='pullDownIcon'></span><span class='pullDownLabel'>向下拉以刷新...</span></div>");
            this.targetList.after("<div id='pullUp' class='loading' ><span class='pullUpIcon'></span><span class='pullUpLabel'>上拉加载更多数据...</span></div>");

            this.pullDownEl = this.targetList.prev();
            this.pullUpEl = this.targetList.next();

            this.pullDownEl.show();
            this.pullUpEl.show();

            this.wraper = this.targetList.parent().parent();
            var scrollOptions = { fadeScrollbar: true, vScrollbar: true, hideScrollbar: true, useTransform: true, useTransition: true, probeType: 3, click: true, onScrollEnd: Bridge.fn.bind(this, this.OnScrollEnd), onScrollMove: Bridge.fn.bind(this, this.OnScrollMove) };
            if (!showScrollBar) {
                scrollOptions.fadeScrollbar = false;
                scrollOptions.vScrollbar = false;
            } else {
                scrollOptions.scrollbars = true;
                scrollOptions.fadeScrollbars = true;
            }

            this.iscroll = new iScroll(this.wraper[0], scrollOptions);

            this.pullDownLabel = this.pullDownEl.find(".pullDownLabel");
            this.pullUpLabel = this.pullUpEl.find(".pullUpLabel");

            this.pullDownEl.hide();
            this.pullUpEl.hide();

        },
        OnScrollMove: function () {
            !Bridge.staticEquals(this.OnScroll, null) ? this.OnScroll() : null;
            if (this.IsLoadingData) {
                return;
            }
            if (this.pullUpEl == null) {
                return;
            }

            if (this.iscroll.distY > 0 && this.iscroll.y > 15) {
                console.info(this.iscroll.distY, this.iscroll.y);

                //不足一页数据
                if (this.MaxPageIndex === JSLib.Mobile.Application.getPageIndexStart()) {
                    if (!this.EnableRefreshData) {
                        return;
                    }
                }
                this.isPullDownBegin = true;
                if (!JSLib.Extension.jQueryEx.IsVisible(this.pullDownEl)) {
                    this.pullDownEl.show();
                    this.pullDownEl[0].className = "flip";
                    this.pullDownLabel.text(JSLib.IScrollWraper.IScrollList.releaseToRefresh);
                }
                return;
            } else {
                console.info("else", this.iscroll.distY, this.iscroll.y);
                this.isPullDownBegin = false;
                this.pullDownEl.hide();
            }

            if (this.iscroll.distY < 0 && this.iscroll.y < (((this.iscroll.maxScrollY - 50) | 0))) {
                if (this.MaxPageIndex === JSLib.Mobile.Application.getPageIndexStart()) {
                    return;
                }
                if (this.ToPageIndex === this.MaxPageIndex) {
                    return;
                }
                this.isPullUpBegin = true;
                if (!JSLib.Extension.jQueryEx.IsVisible(this.pullUpEl)) {
                    this.pullUpEl.show();
                    this.pullUpEl[0].className = "flip";
                    this.pullUpLabel.text(JSLib.IScrollWraper.IScrollList.releaseToRefresh);
                    JSLib.Util.IsScrollExtension.CheckRefresh(this.iscroll);
                }
            } else {
                //Console.info("else", iscroll.distY, iscroll.y);
                this.isPullUpBegin = false;
                //pullUpEl.Hide();
            }

        },
        OnScrollEnd: function () {
            JSLib.Util.IsScrollExtension.CheckRefresh(this.iscroll);

            if (this.isPullUpBegin) {
                if (this.pullUpEl.hasClass("flip")) {
                    this.pullUpEl[0].className = "loading";
                    this.pullUpLabel.text("载入中...");
                }
                this.isPullUpBegin = false;
                this.OnPullToEnd(JSLib.IScrollWraper.IScrollList.PullDirection.Up);
                return;
            } else {
                this.pullUpEl.hide();
            }


            if (this.isPullDownBegin) {
                if (this.pullDownEl.hasClass("flip")) {
                    this.pullDownEl[0].className = "loading";
                    this.pullDownLabel.text("载入中...");
                }
                this.isPullDownBegin = false;
                this.OnPullToEnd(JSLib.IScrollWraper.IScrollList.PullDirection.Down);
                return;
            }
        },
        OnPullToEnd: function (direction) {
            var $step = 0,
                $task1, 
                $taskResult1, 
                $jumpFromFinally, 
                result, 
                addHeight, 
                removedHeight, 
                limitCount, 
                haveCount, 
                removeElement, 
                beginCount, 
                removeElement1, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    for (;;) {
                        $step = System.Array.min([0,1,2,3], $step);
                        switch ($step) {
                            case 0: {
                                if (this.IsLoadingData) {
                                        return;
                                    }
                                    if (direction === JSLib.IScrollWraper.IScrollList.PullDirection.Down) {
                                        if (this.FromPageIndex === JSLib.Mobile.Application.getPageIndexStart()) {
                                            this.ReLoad();
                                            return;
                                        }
                                        this.FromPageIndex = (this.FromPageIndex - 1) | 0;
                                        this.currentPageIndex = (this.currentPageIndex - 1) | 0;

                                    } else if (direction === JSLib.IScrollWraper.IScrollList.PullDirection.Up) {

                                        if (this.ToPageIndex >= this.MaxPageIndex) {
                                            console.info("  pullUpEl.Hide();");
                                            this.pullUpEl.hide();
                                            return;
                                        }
                                        if (JSLib.JSLibConfig.IsUseZepto) {
                                            this.iscroll.maxScrollY = (this.iscroll.maxScrollY - (this.pullUpEl.height())) | 0;
                                        } else {
                                            this.iscroll.maxScrollY = (this.iscroll.maxScrollY - (this.pullUpEl.outerHeight())) | 0;
                                        }
                                        //iscroll.scrollTo(0, iscroll.maxScrollY, 0, false);

                                        this.ToPageIndex = (this.ToPageIndex + 1) | 0;
                                        this.currentPageIndex = (this.currentPageIndex + 1) | 0;
                                    }

                                    if (!Bridge.staticEquals(this.getGetPageData(), null)) {
                                        $step = 1;
                                        continue;
                                    } 
                                    $step = 3;
                                    continue;
                            }
                            case 1: {
                                this.IsLoadingData = true;
                                    $task1 = this.getGetPageData()(this.currentPageIndex);
                                    $step = 2;
                                    $task1.continueWith($asyncBody, true);
                                    return;
                            }
                            case 2: {
                                $taskResult1 = $task1.getAwaitedResult();
                                result = $taskResult1;
                                    this.IsLoadingData = false;

                                    if (direction === JSLib.IScrollWraper.IScrollList.PullDirection.Up && (result.RecordCount < this.PageSize)) {
                                        this.MaxPageIndex = this.ToPageIndex;
                                    }

                                    addHeight = 0;
                                    //绑定数据
                                    if (result.RecordCount !== 0) {
                                        if (direction === JSLib.IScrollWraper.IScrollList.PullDirection.Up) {
                                            this.targetList.append(result.ResultElement);
                                        } else {
                                            this.targetList.prepend(result.ResultElement);
                                        }
                                    }
                                    result.ResultElement = null;
                                    result = null;


                                    removedHeight = 0;
                                    if (this.autoRemoveDom) {
                                        limitCount = (this.LimitPageCount * this.PageSize) | 0;
                                        haveCount = this.targetList.children().length;

                                        if (haveCount > limitCount) {
                                            if (direction === JSLib.IScrollWraper.IScrollList.PullDirection.Up) {
                                                removeElement = this.targetList.find(System.String.format(">:nth-child(-n+{0})", this.PageSize));
                                                removedHeight = (removedHeight + (JSLib.Extension.jQueryEx.TotalHeight(removeElement))) | 0;
                                                removeElement.unbind();
                                                removeElement.remove();
                                                removeElement = null;
                                                this.FromPageIndex = (this.FromPageIndex + 1) | 0;
                                            } else {
                                                beginCount = ((((Bridge.Int.div(haveCount, this.PageSize)) | 0)) * this.PageSize) | 0;
                                                removeElement1 = this.targetList.find(System.String.format(">:nth-child(n+{0})", beginCount));
                                                removedHeight = (removedHeight + (JSLib.Extension.jQueryEx.TotalHeight(removeElement1))) | 0;
                                                removeElement1.unbind();
                                                removeElement1.remove();
                                                removeElement1 = null;
                                                this.ToPageIndex = (this.ToPageIndex - 1) | 0;
                                            }
                                        }

                                    }

                                    this.Refresh();


                                    //targetList.Children().Each(delegate(int index, Element element)
                                    //      {
                                    //          if (index < PageSize)
                                    //          {
                                    //              addHeight += element.TojQuery().GetHeight();
                                    //          }
                                    //      });

                                    //if (direction == PullDirection.Up)
                                    //{
                                    //    if (removedHeight > 0)
                                    //    {
                                    //        iscroll.scrollTo(0, iscroll.y + addHeight, 0, false);
                                    //    }
                                    //}
                                    //else if (direction == PullDirection.Down)
                                    //{
                                    //    iscroll.scrollTo(0, -addHeight, 0, false);
                                    //}

                                    this.pullUpEl.hide();
                                    console.info("  pullUpEl.Hide();");
                                    this.pullDownEl.hide();
                                    this.Refresh();
                                $step = 3;
                                continue;
                            }
                            case 3: {
                                return;
                            }
                            default: {
                                return;
                            }
                        }
                    }
                }, arguments);

            $asyncBody();
        },
        SetWarperWidth: function (width) {
            this.wraper.width(width);
        },
        Refresh: function () {
            if (this.iscroll != null) {
                this.iscroll.refresh();
            }
        },
        ReLoad: function () {
            var $step = 0,
                $task1, 
                $taskResult1, 
                $jumpFromFinally, 
                result, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    for (;;) {
                        $step = System.Array.min([0,1], $step);
                        switch ($step) {
                            case 0: {
                                this.FromPageIndex = JSLib.Mobile.Application.getPageIndexStart();
                                    this.ToPageIndex = JSLib.Mobile.Application.getPageIndexStart();
                                    this.MaxPageIndex = 2147483647;
                                    this.currentPageIndex = JSLib.Mobile.Application.getPageIndexStart();
                                    $task1 = this.getGetPageData()(JSLib.Mobile.Application.getPageIndexStart());
                                    $step = 1;
                                    $task1.continueWith($asyncBody, true);
                                    return;
                            }
                            case 1: {
                                $taskResult1 = $task1.getAwaitedResult();
                                result = $taskResult1;
                                    this.pullDownEl.hide();
                                    this.targetList.empty();
                                    if (result == null) {
                                        return;
                                    }
                                    if (result.RecordCount < this.PageSize) {
                                        this.MaxPageIndex = JSLib.Mobile.Application.getPageIndexStart();
                                    }
                                    this.targetList.append(result.ResultElement);
                                    this.Refresh();
                                    IScrollEx.GotoTop(this.iscroll);
                                return;
                            }
                            default: {
                                return;
                            }
                        }
                    }
                }, arguments);

            $asyncBody();
        },
        Destroy: function () {
            if (this.iscroll != null) {
                this.iscroll.destroy();
                this.iscroll = null;
            }

            //targetList.Remove();
            //pullDownLabel.Remove();
            //pullUpLabel.Remove();
            //pullUpEl.Remove();
            //pullDownEl.Remove();
            //wraper.Remove();


            this.pullDownLabel = null;
            this.pullUpLabel = null;
            this.pullUpEl = null;
            this.pullDownEl = null;
            this.targetList = null;
            this.wraper = null;


            this.setGetPageData(null);
        },
        Disable: function () {
            if (this.iscroll != null) {
                this.iscroll.disable();
            }
        },
        Enable: function () {
            if (this.iscroll != null) {
                this.iscroll.enable();
            }
        }
    });

    Bridge.define("JSLib.IScrollWraper.IScrollList.PullDirection", {
        $kind: "enum",
        statics: {
            Up: 1,
            Down: 2
        }
    });

    Bridge.define("JSLib.IScrollWraper.NaivgateBar", {
        menuScroll: null,
        datalist: null,
        config: {
            events: {
                OnItemClick: null
            }
        },
        ctor: function (parent, navigateOption) {
            this.$initialize();            var $t;

            var wrap = $("<div class='menu'><ul></ul></div>");

            this.datalist = wrap.children("ul");

            var sb = new System.Text.StringBuilder();
            $t = Bridge.getEnumerator(navigateOption);
            while ($t.moveNext()) {
                var n = $t.getCurrent();
                sb.append(System.String.format("<li data-sid='{0}' data-title='{1}' class='{3}'><i style='background-image: url({1})'></i><span>{2}</span></li>", n.Data, n.IconImageUrl, n.Title, n.IsActivated ? "active" : ""));
            }
            this.datalist.append(sb.toString());


            this.datalist.on("click", "li", Bridge.fn.bind(this, $asm.$.JSLib.IScrollWraper.NaivgateBar.f1));

            $(parent).append(wrap);


            var totalWidth = 0;
            this.datalist.children().each(function (index, element) {
                totalWidth = (totalWidth + ($(element).outerWidth())) | 0;
            });
            this.datalist.width(totalWidth);


            this.menuScroll = new iScroll(wrap.get(0), { hScroll: true, lockDirection: true, hScrollbar: false, vScrollbar: false, checkDOMChanges: true });
            this.menuScroll.refresh();

            //datalist.Find("li>span").Each(delegate(int index, Element element)
            //       {
            //           element.Style.MarginLeft = (-(element.TojQuery().GetOuterWidth() / 2)).ToString() + "px";
            //       });

            //Window.SetTimeout(adjustText, 1000);
            //Window.SetTimeout(adjustText, 2000);

    },
    adjustText: function () {
        this.datalist.find("li>span").each($asm.$.JSLib.IScrollWraper.NaivgateBar.f2);
    },
    ClickFirst: function () {
        this.datalist.children().first().click();
    },
    SetActived: function (data) {
        this.datalist.find("li").removeClass("active");
        this.datalist.find(System.String.concat("li[data-sid=", data, "]")).addClass("active");
    }
    });

    Bridge.ns("JSLib.IScrollWraper.NaivgateBar", $asm.$);

    Bridge.apply($asm.$.JSLib.IScrollWraper.NaivgateBar, {
        f1: function (event) {
            this.datalist.find("li.active").removeClass("active");
            $(event.currentTarget).addClass("active");
            !Bridge.staticEquals(this.OnItemClick, null) ? this.OnItemClick(this, Bridge.merge(new JSLib.IScrollWraper.NavigateClickArgs(), {
                    Data: $(event.currentTarget).attr("data-sid"),
                    Title: $(event.currentTarget).attr("data-title")
                } )) : null;
        },
        f2: function (index, element) {
            element.style.marginLeft = (((-(((Bridge.Int.div($(element).outerWidth(), 2)) | 0))) | 0)) + "px";
        }
    });

    Bridge.define("JSLib.IScrollWraper.NavigateBarOption", {
        Data: null,
        Title: null,
        IconImageUrl: null,
        IsActivated: false
    });

    Bridge.define("JSLib.IScrollWraper.NavigateClickArgs", {
        Data: null,
        Title: null
    });

    Bridge.define("JSLib.IScrollWraper.PageData", {
        RecordCount: 0,
        ResultElement: null,
        PageIndex: 0,
        config: {
            init: function () {
                this.PageIndex = JSLib.Mobile.Application.getPageIndexStart();
            }
        }
    });

    Bridge.define("JSLib.JSLibConfig", {
        statics: {
            IsUseZepto: false,
            PageTransitionEffect: true
        }
    });

    Bridge.define("JSLib.Map.BaiduGeocodingService", {
        GetLocationAddress: function (baiduMapKey, lng, lat) {
            var tsk = new System.Threading.Tasks.TaskCompletionSource();
            var options = { dataType: "jsonp", url: System.String.format("http://api.map.baidu.com/geocoder/v2/?ak={0}&location={1},{2}&output=json&pois=0", baiduMapKey, lat, lng), success: function (data, status, request) {
                var result = data;
                tsk.setResult(result.result.formatted_address);
                ConsoleEx.Dump(Object, data);
            }, error: function (request, status, error) {
                tsk.setResult(null);
            } };
            $.ajax(options);
            return tsk.task;
        }
    });

    Bridge.define("JSLib.Map.DbGeographyValue", {
        CoordinateSystemId: 0,
        WellKnownText: null
    });

    Bridge.define("JSLib.Map.GeographyEx", {
        statics: {
            ToPoint: function (target) {
                //POINT (104.074895 30.540493)
                var text = target.Geography.WellKnownText;
                return JSLib.Map.GeographyEx.ToPoint$1(text);
            },
            ToPoint$1: function (target) {
                if (System.String.isNullOrEmpty(target)) {
                    throw new System.Exception("不正确的经纬度格式!");
                }
                var result = target.match(new RegExp("(\\d+\\.?\\d*) (\\d+\\.?\\d*)"));
                return new BMap.Point(System.Double.parse(result[1]), System.Double.parse(result[2]));
            }
        }
    });

    Bridge.define("JSLib.Map.GeographyType", {
        Geography: null
    });

    Bridge.define("JSLib.MapPoint", {
        Address: "",
        Lng: 0,
        Lat: 0,
        Title: null,
        $ctor1: function (lng, lat, address, Title) {
            if (Title === void 0) { Title = ""; }

            this.$initialize();
            this.Lng = lng;
            this.Lat = lat;
            this.Address = address;
            this.Title = Title;
        },
        ctor: function () {
            this.$initialize();
        }
    });

    Bridge.define("JSLib.Mobile.Application", {
        statics: {
            ctor: function () {
                //检查 机器类型;
                var userAgent = window.navigator.userAgent;
                if (userAgent.match(new RegExp("(iPhone|iPod|iPad)")) != null) {
                    JSLib.Mobile.Application.DeviceType = JSLib.Mobile.DeviceType.Iphone;
                } else if (userAgent.match(new RegExp("Android")) != null) {
                    JSLib.Mobile.Application.DeviceType = JSLib.Mobile.DeviceType.Android;
                } else {
                    JSLib.Mobile.Application.DeviceType = JSLib.Mobile.DeviceType.Unknown;
                }

                if (JSLib.Mobile.Application.DeviceType === JSLib.Mobile.DeviceType.Unknown) {
                    JSLib.Mobile.Application.IsBrowser = true;
                }

                JSLib.Mobile.Application.RegisterCommonEvent();

            },
            DisableBodyMove: true,
            CordovaJSDir: "./Resources/JS/",
            PageCssSelector: ".ui-page",
            NetWorkState: 1,
            IsBrowser: false,
            AutoLoadCss: true,
            PreserveCss: true,
            LoadCssForce: false,
            PageIndexFromZero: true,
            EnableSwipeLeftToRightToBack: false,
            EnableSwipeRightToLeftFoward: false,
            BeforeBack: null,
            DeviceType: 0,
            ApplicationMode: 1,
            WebRequestTimeOut: 300000,
            BaiduKey: "lh0NnX14v1EFe2H2U00TseO3",
            _baseNameSpace: null,
            RootPath: "../Pages/",
            EnableSystemLog: false,
            CurrentHashString: "",
            config: {
                events: {
                    OnUserLocationChange: null,
                    OnApplicationError: null,
                    OnHashChange: null
                }
            },
            getPageIndexStart: function () {
                if (JSLib.Mobile.Application.PageIndexFromZero) {
                    return 0;
                } else {
                    return 1;
                }
            },
            getGeoLocation: function () {
                var location = window.localStorage.userLocation;
                if (location != null) {
                    return Bridge.merge(Bridge.createInstance(JSLib.Mobile.UserGeoLocation), JSON.parse(location));
                }
                return null;
            },
            setGeoLocation: function (value) {
                window.localStorage.userLocation = JSON.stringify(value);
            },
            getIsWeixin: function () {
                return System.String.indexOf(window.navigator.userAgent, "MicroMessenger") !== -1;
            },
            getIsCannotGoBack: function () {
                return window.history.length === 1;
            },
            getBaseNameSpace: function () {
                if (System.String.isNullOrEmpty(JSLib.Mobile.Application._baseNameSpace)) {
                    throw new System.Exception("未设置页面命名空间，通常情况该值为 PhoneResource.Pages");
                }
                return JSLib.Mobile.Application._baseNameSpace;
            },
            setBaseNameSpace: function (value) {
                JSLib.Mobile.Application._baseNameSpace = value;
            },
            OnDeviceReady: function (action) {
                document.addEventListener("deviceready", function (event1) {
                    action();
                });
            },
            ListenNetWorkState: function () {
                document.addEventListener("online", $asm.$.JSLib.Mobile.Application.f1);

                document.addEventListener("offline", $asm.$.JSLib.Mobile.Application.f2);
            },
            PrepareApp: function () {
                if (JSLib.Mobile.Application.DisableBodyMove) {
                    JSLib.Mobile.MobilePage.PageContainer.on("touchmove", $asm.$.JSLib.Mobile.Application.f3);
                }
                if (!JSLib.Mobile.Application.IsBrowser) {
                    ConsoleEx.Dump(String, ("设备信息:" + System.Enum.toString(JSLib.Mobile.DeviceType, JSLib.Mobile.Application.DeviceType)));
                    //LoadDevicePhoneGapJs();
                }

                if (JSLib.Mobile.MobilePage.PageContainer == null) {
                    JSLib.Mobile.MobilePage.PageContainer = $("body");
                }

                //处理andorid上数字输入框不能与placeholder兼容的问题
                JSLib.Mobile.Application.HandleAndroidNumberTextBox();
            },
            Back: function (backPageCount) {
                var $step = 0,
                    $task1, 
                    $taskResult1, 
                    $jumpFromFinally, 
                    foo, 
                    focusElement, 
                    Attr, 
                    isTextBox, 
                    isTextArea, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3], $step);
                            switch ($step) {
                                case 0: {
                                    if (backPageCount === void 0) { backPageCount = 1; }

                                        //如果为下拉列表展开状态，则关闭下拉列表
                                        //if (SelectMenu.Hide())
                                        //{
                                        //    return;
                                        //}

                                        //如果为下拉列表展开状态，则关闭下拉列表
                                        //if (ModalPanel.modalPanles != null && ModalPanel.modalPanles.Count > 0)
                                        //{
                                        //    var data = ModalPanel.modalPanles[ModalPanel.modalPanles.Count - 1];
                                        //    data.Destroy();
                                        //    return;
                                        //}

                                        if (!Bridge.staticEquals(JSLib.Mobile.Application.BeforeBack, null)) {
                                            $step = 1;
                                            continue;
                                        } 
                                        $step = 3;
                                        continue;
                                }
                                case 1: {
                                    $task1 = JSLib.Mobile.Application.BeforeBack();
                                        $step = 2;
                                        $task1.continueWith($asyncBody, true);
                                        return;
                                }
                                case 2: {
                                    $taskResult1 = $task1.getAwaitedResult();
                                    foo = $taskResult1;
                                        if (!foo) {
                                            return;
                                        }
                                    $step = 3;
                                    continue;
                                }
                                case 3: {
                                    
                                        //如果文本框处于焦点状态，则取消该元素处于焦点状态
                                        JSLib.Mobile.NavigationManager.CurrentBackPageCount = backPageCount;
                                        if (!JSLib.Mobile.Application.IsBrowser) {
                                            focusElement = document.activeElement;
                                            Attr = focusElement.getAttribute("type");
                                            isTextBox = focusElement != null && Bridge.referenceEquals(focusElement.tagName.toUpperCase(), "INPUT") && focusElement.hasAttribute("type") && (Bridge.referenceEquals(Attr, "text") || Bridge.referenceEquals(Attr, "password"));
                                            isTextArea = focusElement != null && Bridge.referenceEquals(focusElement.tagName.toUpperCase(), "TEXTAREA");
                                            if (isTextBox || isTextArea) {
                                                focusElement.blur();
                                            } else {
                                                //Window.History.Back();
                                                JSLib.Mobile.NavigationManager.HistoryBack();
                                            }
                                        } else {
                                            //Window.History.Back();
                                            JSLib.Mobile.NavigationManager.HistoryBack();
                                        }
                                    return;
                                }
                                default: {
                                    return;
                                }
                            }
                        }
                    }, arguments);

                $asyncBody();
            },
            BackTo: function (T) {
                //查找app是否存有该指定要后退到的页面，如果不存在，则取消后退
                if (System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).all(function (n) {
                        return !Bridge.referenceEquals(n.PageData.PageType, T);
                    })) {
                    JSLib.Mobile.Application.SystemLog("指定后退到页面并不存在于历史记录中，取消后退操作!");
                    return;
                }
                JSLib.Mobile.NavigationManager.CurrentBackPageType = T;
                JSLib.Mobile.Application.Back();
            },
            Foward: function () {
                //Window.History.Forward();
                //暂时不实现前进功能
            },
            ShowLoading: function () {
                $("body").addClass("c-loading");
            },
            HideLoading: function () {
                $("body").removeClass("c-loading");
            },
            SetUserLocation: function (lon, lat, addr) {
                var userGeoLocation = Bridge.merge(new JSLib.Mobile.UserGeoLocation(), {
                    Lontitiude: lon,
                    Latitude: lat,
                    Address: addr
                } );
                JSLib.Mobile.Application.setGeoLocation(userGeoLocation);
                if (!Bridge.staticEquals(JSLib.Mobile.Application.OnUserLocationChange, null)) {
                    JSLib.Mobile.Application.OnUserLocationChange(null, Bridge.merge(new JSLib.Mobile.UserGeoLocationArgs(), {
                        LocationData: userGeoLocation
                    } ));
                }
            },
            HandleAndroidNumberTextBox: function () {
                $(document).on("focusin", "input[data-number]", $asm.$.JSLib.Mobile.Application.f4);
                $(document).on("focusout", "input[data-number]", $asm.$.JSLib.Mobile.Application.f5);
            },
            RegisterCommonEvent: function () {
                JSLib.Mobile.Application.HandleAndroidNumberTextBox();

            },
            RaiseError: function (errorData) {
                if (!Bridge.staticEquals(JSLib.Mobile.Application.OnApplicationError, null)) {
                    JSLib.Mobile.Application.OnApplicationError(null, errorData);
                }
            },
            SystemLog: function (message) {
                if (JSLib.Mobile.Application.EnableSystemLog) {
                    console.log(message, Bridge.Date.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
                }
            },
            SystemLog$1: function (tag, message) {
                if (JSLib.Mobile.Application.EnableSystemLog) {
                    console.log(tag, message, Bridge.Date.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
                }
            },
            ChangeHash: function (hashString) {
                if (System.String.startsWith(hashString, "#")) {
                    JSLib.Mobile.Application.CurrentHashString = hashString.substr(1, ((hashString.length - 1) | 0));
                } else {
                    JSLib.Mobile.Application.CurrentHashString = hashString;
                }
                //Window.Location.Replace(JSLib.Util.URL.GetAllExceptHash() + "#" + CurrentHashString);
                JSLib.Mobile.Application.SystemLog$1("当前Hash:", JSLib.Mobile.Application.CurrentHashString);
                if (!Bridge.staticEquals(JSLib.Mobile.Application.OnHashChange, null)) {
                    JSLib.Mobile.Application.OnHashChange(null, Bridge.merge(new JSLib.Mobile.HashChangeArgs(), {
                        HashString: JSLib.Mobile.Application.CurrentHashString
                    } ));
                }
            }
        }
    });

    Bridge.ns("JSLib.Mobile.Application", $asm.$);

    Bridge.apply($asm.$.JSLib.Mobile.Application, {
        f1: function (event) {
            console.info("联机状态");
            JSLib.Mobile.Application.NetWorkState = JSLib.Mobile.NetWorkState.OnLine;
        },
        f2: function (event) {
            console.info("脱机状态");
            JSLib.Mobile.Application.NetWorkState = JSLib.Mobile.NetWorkState.OffLine;
        },
        f3: function (event) {
            event.preventDefault();
        },
        f4: function (event) {
            event.currentTarget.setAttribute("data-oritype", event.currentTarget.getAttribute("type"));
            event.currentTarget.type = "number";
        },
        f5: function (event) {
            event.currentTarget.setAttribute("type", event.currentTarget.getAttribute("data-oritype"));
        }
    });

    Bridge.define("JSLib.Mobile.ApplicationErrorArgs", {
        ErrorMessage: null,
        Stack: null
    });

    Bridge.define("JSLib.Mobile.ApplicationMode", {
        $kind: "enum",
        statics: {
            WebMode: 1,
            DeviceMode: 2
        }
    });

    Bridge.define("JSLib.Mobile.IShowLoading", {
        $kind: "interface"
    });

    Bridge.define("JSLib.Mobile.DeviceType", {
        $kind: "enum",
        statics: {
            Unknown: 0,
            Iphone: 1,
            Android: 10,
            Desktop: 20
        }
    });

    Bridge.define("JSLib.Mobile.HashChangeArgs", {
        HashString: null
    });

    Bridge.define("JSLib.Mobile.MessageBox", {
        statics: {
            ConfirmHandler: null,
            AlertHandler: null,
            Confirm: function (message, title) {
                var $step = 0,
                    $task1, 
                    $taskResult1, 
                    $jumpFromFinally, 
                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                    $returnValue, 
                    $async_e, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        try {
                            for (;;) {
                                $step = System.Array.min([0,1,2,3,4], $step);
                                switch ($step) {
                                    case 0: {
                                        if (title === void 0) { title = "确认框"; }
                                            if (!Bridge.staticEquals(JSLib.Mobile.MessageBox.ConfirmHandler, null)) {
                                                $step = 1;
                                                continue;
                                            } else  {
                                                $step = 3;
                                                continue;
                                            }
                                    }
                                    case 1: {
                                        $task1 = JSLib.Mobile.MessageBox.ConfirmHandler(message);
                                            $step = 2;
                                            $task1.continueWith($asyncBody);
                                            return;
                                    }
                                    case 2: {
                                        $taskResult1 = $task1.getAwaitedResult();
                                        $tcs.setResult($taskResult1);
                                            return;
                                    }
                                    case 3: {
                                        $tcs.setResult(window.confirm(message, title));
                                            return;
                                    }
                                    case 4: {
                                        $tcs.setResult(null);
                                        return;
                                    }
                                    default: {
                                        $tcs.setResult(null);
                                        return;
                                    }
                                }
                            }
                        } catch($async_e1) {
                            $async_e = System.Exception.create($async_e1);
                            $tcs.setException($async_e);
                        }
                    }, arguments);

                $asyncBody();
                return $tcs.task;
            },
            Alert: function (message, title) {
                if (title === void 0) { title = "警告"; }
                if (!Bridge.staticEquals(JSLib.Mobile.MessageBox.AlertHandler, null)) {
                    JSLib.Mobile.MessageBox.AlertHandler(message);
                    return;
                }
                window.alert(message, title);
            }
        }
    });

    Bridge.define("JSLib.Mobile.MobilePage", {
        statics: {
            ctor: function () {
                JSLib.Mobile.MobilePage.DomPageRepository = new (System.Collections.Generic.List$1(JSLib.Mobile.PageInstanceData))();
            },
            AutoRecyclePages: true,
            showLoadingMessage: true,
            CurrentPage: null,
            IsForwarding: false,
            IsEntryPage: true,
            DomPageRepository: null,
            AllMobilePageTypes: null,
            CurrentPageZIndex: 1,
            OnNavigatingPage: null,
            PageContainer: null,
            config: {
                init: function () {
                    this.AllMobilePageTypes = new (System.Collections.Generic.List$1(Function))();
                }
            },
            GeneratePageId$1: function (targetType, initialData) {
                if (initialData === void 0) { initialData = null; }
                var page = System.String.replaceAll(Bridge.Reflection.getTypeFullName(targetType), ".", "-");
                var pageData = "";
                if (initialData != null) {
                    pageData = System.String.concat("--", System.Convert.toBase64String(JSLib.CommonService.GetBytes(JSON.stringify(initialData)), null, null, null));
                }
                return System.String.concat(page, pageData);
            },
            GeneratePageId: function (targetType, initialData) {
                if (initialData === void 0) { initialData = null; }
                var pageData = "";
                if (initialData != null) {
                    pageData = System.String.concat("--", System.Convert.toBase64String(JSLib.CommonService.GetBytes(JSON.stringify(initialData)), null, null, null));
                }
                return System.String.concat(targetType, pageData);
            },
            Prepare: function (mobilePageTypes, autoLoad, defaultHash) {
                var $t;
                if (autoLoad === void 0) { autoLoad = true; }
                if (defaultHash === void 0) { defaultHash = null; }
                JSLib.Mobile.MobilePage.AllMobilePageTypes = mobilePageTypes;
                var mobilePageDics = new (System.Collections.Generic.Dictionary$2(String,Function))();
                $t = Bridge.getEnumerator(mobilePageTypes);
                while ($t.moveNext()) {
                    var typeItem = $t.getCurrent();
                    mobilePageDics.add(System.String.replaceAll(Bridge.Reflection.getTypeFullName(typeItem), ".", "-"), typeItem);
                }
                JSLib.Mobile.PageLoader.RegisterMobilePages = mobilePageDics;

                //jQuery.Window.On("hashchange", delegate(jQueryEvent @event)
                //{

                JSLib.Mobile.Application.addOnHashChange(function (sender, args) {
                    var hashstring = args.HashString;
                    //如果后退到入口页，则不做任何事
                    if (System.String.isNullOrEmpty(hashstring)) {
                        if (!System.String.isNullOrEmpty(defaultHash)) {
                            hashstring = defaultHash;
                        } else {
                            return;
                        }
                    }
                    if (JSLib.Mobile.MobilePage.IsForwarding) {
                        JSLib.Mobile.MobilePage.IsForwarding = false;
                        return;
                    } else {
                        var currentPageData = JSLib.Mobile.PageData.FromHashString(hashstring);

                        //如果当前页与目标页之间数量大于1，则提前销毁中间页面
                        if (JSLib.Mobile.NavigationManager.CurrentBackPageCount > 1) {
                            //获取当前中间页面，并且销毁
                            if (System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).any(function (n) {
                                    return n.PageData.GetHashCode() === currentPageData.GetHashCode();
                                })) {
                                System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).first(function (n) {
                                        return n.PageData.GetHashCode() === currentPageData.GetHashCode();
                                    }).BasePage.Destroy();
                            }
                            JSLib.Mobile.NavigationManager.CurrentBackPageCount = (JSLib.Mobile.NavigationManager.CurrentBackPageCount - 1) | 0;
                            JSLib.Mobile.Application.Back(1);
                            return;
                        }

                        //如果指定了后退到页面，则执行连续后退，直到遇到指定的页面类型为止
                        if (JSLib.Mobile.NavigationManager.CurrentBackPageType != null) {

                            if (!Bridge.referenceEquals(currentPageData.PageType, JSLib.Mobile.NavigationManager.CurrentBackPageType)) {
                                //获取当前中间页面，并且销毁
                                if (System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).any(function (n) {
                                        return n.PageData.GetHashCode() === currentPageData.GetHashCode();
                                    })) {
                                    System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).first(function (n) {
                                            return n.PageData.GetHashCode() === currentPageData.GetHashCode();
                                        }).BasePage.Destroy();
                                    JSLib.Mobile.Application.Back();
                                }
                                return;
                            } else {
                                JSLib.Mobile.NavigationManager.CurrentBackPageType = null;
                            }
                        }


                        if (currentPageData.PageType == null) {
                            return;
                        }

                        JSLib.Mobile.Application.SystemLog$1("后退页面!", Bridge.Reflection.getTypeFullName(currentPageData.PageType));
                        JSLib.Mobile.MobilePage.OnNavigateToPage(currentPageData, true);
                    }

                });


                //});

                if (autoLoad) {
                    JSLib.Mobile.Application.SystemLog("----autoload");
                    //如果地址栏存在页面信息数据,则自动加载该页面
                    JSLib.Mobile.Application.CurrentHashString = window.location.hash;
                    if (System.String.isNullOrEmpty(JSLib.Mobile.Application.CurrentHashString)) {
                        return false;
                    }
                    var pageData = JSLib.Mobile.PageData.FromHashString(JSLib.Mobile.Application.CurrentHashString);
                    if (pageData == null) {
                        return false;
                    }
                    JSLib.Mobile.MobilePage.IsEntryPage = false;
                    JSLib.Mobile.Application.SystemLog("----OnNavigateToPage");
                    JSLib.Mobile.NavigationManager.HistoryData.add(JSLib.Mobile.Application.CurrentHashString);
                    JSLib.Mobile.MobilePage.OnNavigateToPage(pageData, false, null);
                    return true;

                }

                return false;
            },
            GotoPage$1: function (TMobilePage, initialData, OnPageShow) {
                if (initialData === void 0) { initialData = null; }
                if (OnPageShow === void 0) { OnPageShow = null; }
                if (!Bridge.staticEquals(JSLib.Mobile.MobilePage.OnNavigatingPage, null)) {
                    if (!JSLib.Mobile.MobilePage.OnNavigatingPage(TMobilePage)) {
                        return;
                    }
                }
                JSLib.SingleTask.Enquee(function () {
                    var $step = 0,
                        $task1, 
                        $jumpFromFinally, 
                        $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                        $returnValue, 
                        pageType, 
                        pageHash, 
                        $async_e, 
                        $asyncBody = Bridge.fn.bind(this, function () {
                            try {
                                for (;;) {
                                    $step = System.Array.min([0,1,2,3], $step);
                                    switch ($step) {
                                        case 0: {
                                            pageType = TMobilePage;
                                                pageHash = JSLib.Mobile.MobilePage.GeneratePageId$1(pageType, initialData);
                                                JSLib.Mobile.MobilePage.ForwardPage(TMobilePage, pageHash, OnPageShow);

                                                if (JSLib.Mobile.Application.DeviceType === JSLib.Mobile.DeviceType.Android) {
                                                    $step = 1;
                                                    continue;
                                                } 
                                                $step = 3;
                                                continue;
                                        }
                                        case 1: {
                                            $task1 = System.Threading.Tasks.Task.delay(500);
                                                $step = 2;
                                                $task1.continueWith($asyncBody);
                                                return;
                                        }
                                        case 2: {
                                            $task1.getAwaitedResult();
                                            $step = 3;
                                            continue;
                                        }
                                        case 3: {
                                            $tcs.setResult(null);
                                            return;
                                        }
                                        default: {
                                            $tcs.setResult(null);
                                            return;
                                        }
                                    }
                                }
                            } catch($async_e1) {
                                $async_e = System.Exception.create($async_e1);
                                $tcs.setException($async_e);
                            }
                        }, arguments);

                    $asyncBody();
                    return $tcs.task;
                });

            },
            GotoPage: function (pageTypeStr, initialData, OnPageShow) {
                if (initialData === void 0) { initialData = null; }
                if (OnPageShow === void 0) { OnPageShow = null; }
                if (System.String.isNullOrEmpty(pageTypeStr)) {
                    throw new System.ArgumentException("{pageTypeStr}不能为空");
                }
                var pageHash = JSLib.Mobile.MobilePage.GeneratePageId(System.String.replaceAll(pageTypeStr, ".", "-"), initialData);
                JSLib.Mobile.MobilePage.ForwardPage(JSLib.Mobile.BasePage, pageHash, OnPageShow);
            },
            GotoPageDynamic: function (pageSpace, pageName, inlitialData, OnPageShow) {
                if (OnPageShow === void 0) { OnPageShow = null; }
                var type = JSLib.Mobile.PageLoader.LoadPageType$1(pageSpace, pageName);
                if (!Bridge.staticEquals(JSLib.Mobile.MobilePage.OnNavigatingPage, null)) {
                    if (!JSLib.Mobile.MobilePage.OnNavigatingPage(type)) {
                        return;
                    }
                }
                var pageHash = JSLib.Mobile.MobilePage.GeneratePageId$1(type, inlitialData);
                JSLib.Mobile.MobilePage.ForwardPage(JSLib.Mobile.BasePage, pageHash, OnPageShow);
            },
            ForwardPage: function (TMobilePage, pageHash, OnPageShow) {
                if (OnPageShow === void 0) { OnPageShow = null; }

                JSLib.Mobile.MobilePage.IsForwarding = true;

                JSLib.Mobile.NavigationManager.HistoryData.add(pageHash);
                JSLib.Mobile.Application.ChangeHash(pageHash);

                var pageData = JSLib.Mobile.PageData.FromHashString(pageHash);
                if (pageData != null) {
                    JSLib.Mobile.MobilePage.OnNavigateToPage(pageData, false, OnPageShow);
                }

            },
            OnNavigateToPage: function (pageData, isBack, OnPageShow) {
                if (isBack === void 0) { isBack = false; }
                if (OnPageShow === void 0) { OnPageShow = null; }
                var pageInstance;
                if (System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).any(function (n) {
                        return n.PageData.GetHashCode() === pageData.GetHashCode();
                    })) {
                    JSLib.Mobile.Application.SystemLog("全局页面实例中包含此页面对象");
                    pageInstance = System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).first(function (n) {
                            return n.PageData.GetHashCode() === pageData.GetHashCode();
                        }).BasePage;
                } else {
                    if (!JSLib.Mobile.MobilePage.AllMobilePageTypes.contains(pageData.PageType)) {
                        console.error("未找到此页面:", pageData);
                        return;
                    }
                    pageInstance = Bridge.cast(Bridge.createInstance(pageData.PageType), JSLib.Mobile.BasePage);

                    pageInstance.InitialData = CoreEx.CloneBySerilization(Object, pageData.PageInitialData);
                }

                JSLib.Mobile.MobilePage.HandleChangePage(JSLib.Mobile.BasePage, pageInstance, pageData, OnPageShow, isBack);
            },
            HandleChangePage: function (TMobilePage, page, pageData, OnPageShow, isBack) {
                var $step = 0,
                    $task1, 
                    $taskResult1, 
                    $task2, 
                    $taskResult2, 
                    $task3, 
                    $task4, 
                    $task5, 
                    $task6, 
                    $taskResult6, 
                    $task7, 
                    $jumpFromFinally, 
                    $returnValue, 
                    initialData, 
                    pageType, 
                    PrePage, 
                    isExistCss, 
                    $t, 
                    item, 
                    isExistPage, 
                    ex, 
                    innerException, 
                    args, 
                    $async_e, 
                    pageOutClass, 
                    tsk, 
                    onAnimationEnd, 
                    $async_e1, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        try {
                            for (;;) {
                                $step = System.Array.min([0,1,2,3,4,6,7,8,9,11,12,13,15,16,17,18,19,20,21,22,24], $step);
                                switch ($step) {
                                    case 0: {
                                        if (OnPageShow === void 0) { OnPageShow = null; }
                                            if (isBack === void 0) { isBack = false; }
                                            initialData = CoreEx.CloneBySerilization(Object, pageData.PageInitialData);
                                            pageType = pageData.PageType;

                                            JSLib.Mobile.Application.SystemLog("----OnNavigatingPage");
                                            if (!Bridge.staticEquals(JSLib.Mobile.MobilePage.OnNavigatingPage, null)) {
                                                if (!JSLib.Mobile.MobilePage.OnNavigatingPage(pageType)) {
                                                    return;
                                                }
                                            }

                                            if (JSLib.Mobile.MobilePage.CurrentPage != null && Bridge.referenceEquals(Bridge.getType(JSLib.Mobile.MobilePage.CurrentPage), Bridge.getType(page))) {
                                                if (pageData.PageInitialData == null && JSLib.Mobile.MobilePage.CurrentPage.InitialData == null) {
                                                    return;
                                                }
                                                if (Bridge.referenceEquals(pageData.PageInitialData, JSLib.Mobile.MobilePage.CurrentPage.InitialData)) {
                                                    return;
                                                }
                                            }

                                            PrePage = JSLib.Mobile.MobilePage.CurrentPage;
                                            JSLib.Mobile.MobilePage.CurrentPage = page;


                                            //新增并跳转页面
                                            if (page.pageObject == null) {
                                                $step = 1;
                                                continue;
                                            } else  {
                                                $step = 16;
                                                continue;
                                            }
                                    }
                                    case 1: {
                                        JSLib.Mobile.Application.SystemLog("----页面数据为空，新创建页面！");
                                            if (JSLib.Mobile.Application.AutoLoadCss) {
                                                $step = 2;
                                                continue;
                                            } 
                                            $step = 6;
                                            continue;
                                    }
                                    case 2: {
                                        JSLib.Mobile.Application.SystemLog("----AutoLoadCSS");
                                            //加载CSS
                                            isExistCss = false;
                                            $t = Bridge.getEnumerator(JSLib.Mobile.MobilePage.DomPageRepository);
                                            while ($t.moveNext()) {
                                                item = $t.getCurrent();
                                                if (Bridge.referenceEquals(item.PageData.PageType, pageData.PageType)) {
                                                    isExistCss = true;
                                                }
                                            }

                                            if (!isExistCss) {
                                                $step = 3;
                                                continue;
                                            } 
                                            $step = 5;
                                            continue;
                                    }
                                    case 3: {
                                        $task1 = JSLib.Mobile.PageLoader.LoadCss(pageData.PageType);
                                            $step = 4;
                                            $task1.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 4: {
                                        $taskResult1 = $task1.getAwaitedResult();
                                        $step = 5;
                                        continue;
                                    }

                                    case 6: {
                                        
                                            JSLib.Mobile.Application.SystemLog("----PreparePage");

                                            //构建页面dom数据
                                            $task2 = page.PreparePage();
                                            $step = 7;
                                            $task2.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 7: {
                                        $taskResult2 = $task2.getAwaitedResult();
                                        page.pageObject = $taskResult2;

                                            //page.pageObject.Hide();
                                            page.InitialData = CoreEx.CloneBySerilization(Object, initialData);
                                            JSLib.Mobile.MobilePage.PageContainer.append(page.pageObject);
                                            page.InitialComponent();
                                            page.pageObject.attr("data-sid", JSLib.Mobile.MobilePage.GeneratePageId$1(pageType, initialData));
                                            //如果加载的页面中不包含即将跳转的页面，则创建对应的页面，并将其加载到dom树中
                                            isExistPage = System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).any(function (n) {
                                                    return n.PageData.GetHashCode() === new JSLib.Mobile.PageData(pageType, initialData).GetHashCode();
                                                });
                                            if (!isExistPage) {
                                                JSLib.Mobile.MobilePage.DomPageRepository.add(Bridge.merge(new JSLib.Mobile.PageInstanceData(), {
                                                    PageData: new JSLib.Mobile.PageData(pageType, initialData),
                                                    BasePage: page
                                                } ));
                                            }


                                            //直接显示出错页面
                                            if (page.IsPrepareDataError) {
                                                $step = 8;
                                                continue;
                                            } else  {
                                                $step = 10;
                                                continue;
                                            }
                                    }
                                    case 8: {
                                        $task3 = page.Show();
                                            $step = 9;
                                            $task3.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 9: {
                                        $task3.getAwaitedResult();
                                        $step = 15;
                                        continue;
                                    }

                                    case 11: {
                                        page.TriggerInitEvent();
                                            $task4 = page.Show();
                                            $step = 12;
                                            $task4.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 12: {
                                        $task4.getAwaitedResult();
                                        if (PrePage != null) {
                                                PrePage.Hide();
                                            }
                                            if (!Bridge.staticEquals(OnPageShow, null)) {
                                                OnPageShow(page);
                                            }
                                        $step = 14;
                                        continue;
                                    }
                                    case 13: {
                                        console.error(ex);
                                            innerException = null;
                                            innerException = ex;
                                            while (innerException.getInnerException() != null) {
                                                innerException = innerException.getInnerException();
                                            }
                                            args = Bridge.merge(new JSLib.Mobile.ApplicationErrorArgs(), {
                                                ErrorMessage: innerException.getMessage(),
                                                Stack: innerException.getStackTrace()
                                            } );
                                            JSLib.Mobile.Application.RaiseError(args);
                                            $async_e = null;
                                        $step = 14;
                                        continue;
                                    }

                                    case 15: {
                                        
                                            //if (PrePage != null)
                                            //{
                                            //    PrePage.Hide();
                                            //}
                                        $step = 24;
                                        continue;
                                    }
                                    case 16: {
                                        JSLib.Mobile.Application.SystemLog("系统后退操作");

                                            $task5 = System.Threading.Tasks.Task.delay(10);
                                            $step = 17;
                                            $task5.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 17: {
                                        $task5.getAwaitedResult();
                                        //后退
                                            if (PrePage != null) {
                                                $step = 18;
                                                continue;
                                            } 
                                            $step = 23;
                                            continue;
                                    }
                                    case 18: {
                                        
                                            page.pageObject.show();
                                            if (JSLib.JSLibConfig.PageTransitionEffect) {
                                                $step = 19;
                                                continue;
                                            } 
                                            $step = 21;
                                            continue;
                                    }
                                    case 19: {
                                        pageOutClass = PrePage.GetTraslationInOutClass().item2;

                                            tsk = new System.Threading.Tasks.TaskCompletionSource();
                                            onAnimationEnd = null;
                                            onAnimationEnd = function () {
                                                PrePage.pageObject.off("webkitAnimationEnd", onAnimationEnd);
                                                tsk.setResult(null);
                                            };
                                            PrePage.pageObject.on("webkitAnimationEnd", onAnimationEnd);
                                            PrePage.pageObject.addClass(pageOutClass);
                                            //temp add
                                            //PrePage.pageObject.Show();
                                            $task6 = tsk.task;
                                            $step = 20;
                                            $task6.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 20: {
                                        $taskResult6 = $task6.getAwaitedResult();
                                        $step = 21;
                                        continue;
                                    }
                                    case 21: {
                                        $task7 = page.Show(false);
                                            $step = 22;
                                            $task7.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 22: {
                                        $task7.getAwaitedResult();
                                        !Bridge.staticEquals(OnPageShow, null) ? OnPageShow(page) : null;

                                            PrePage.TriggerHideEvent();
                                            //GotoPage导致的后退，不处理前一页面销毁操作
                                            if (isBack) {
                                                PrePage.Destroy();
                                            }
                                        $step = 23;
                                        continue;
                                    }

                                    case 24: {
                                        return;
                                    }
                                    default: {
                                        return;
                                    }
                                }
                            }
                        } catch($async_e1) {
                            $async_e = System.Exception.create($async_e1);
                            if ( $step >= 11 && $step <= 12 ){
                                ex = $async_e;
                                $step = 13;
                                $asyncBody();
                                return;
                            }
                            throw $async_e;
                        }
                    }, arguments);

                $asyncBody();
            }
        }
    });

    Bridge.define("JSLib.Mobile.NavigationManager", {
        statics: {
            HistoryData: null,
            CurrentBackPageCount: 1,
            CurrentBackPageType: null,
            ibackControls: null,
            config: {
                init: function () {
                    this.HistoryData = new (System.Collections.Generic.List$1(String))();
                    this.ibackControls = new (System.Collections.Generic.List$1(JSLib.Widget.IBackEvent))();
                }
            },
            HistoryBack: function () {
                if (JSLib.Mobile.NavigationManager.HistoryData.getCount() > 1) {
                    JSLib.Mobile.NavigationManager.HistoryData.removeAt(((JSLib.Mobile.NavigationManager.HistoryData.getCount() - 1) | 0));
                }
                JSLib.Mobile.Application.ChangeHash(System.Linq.Enumerable.from(JSLib.Mobile.NavigationManager.HistoryData).last());
            },
            BackToRemoveModalPanel: function () {
                var $t;
                $t = Bridge.getEnumerator(JSLib.Mobile.NavigationManager.ibackControls);
                while ($t.moveNext()) {
                    var ibackControl = $t.getCurrent();
                    var args = new JSLib.Widget.BackArgs();
                    ibackControl.JSLib$Widget$IBackEvent$OnBackButton(args);
                    if (!args.IsContinueGoBack) {
                        return false;
                    }
                }
                return true;
            },
            RegisterBackControl: function (backEvent) {
                JSLib.Mobile.NavigationManager.ibackControls.add(backEvent);
            },
            UnRegisterBackControl: function (backEvent) {
                JSLib.Mobile.NavigationManager.ibackControls.remove(backEvent);
            }
        }
    });

    Bridge.define("JSLib.Mobile.NetWorkState", {
        $kind: "enum",
        statics: {
            OnLine: 1,
            OffLine: 2
        }
    });

    Bridge.define("JSLib.Mobile.OrientationChangArgs", {
        OrientationValue: null
    });

    Bridge.define("JSLib.Mobile.PageData", {
        statics: {
            FromHashString: function (hash) {
                var hashData = "";
                if (System.String.startsWith(hash, "#")) {
                    hashData = hash.substr(1, ((hash.length - 1) | 0));
                } else {
                    hashData = hash;
                }
                var inlitialData = "";
                var hashSplitData = hashData.split("--");
                var typedata = hashSplitData[0];
                if (hashSplitData.length === 2) {
                    inlitialData = hashSplitData[1];
                }
                var pageInitialData = System.String.isNullOrEmpty(inlitialData) ? null : JSON.parse(JSLib.CommonService.GetString(System.Convert.fromBase64String(inlitialData)));

                var targetMobilePageType = JSLib.Mobile.PageData.GetTypeFromHash(typedata);
                if (targetMobilePageType == null) {
                    return null;
                }
                return new JSLib.Mobile.PageData(targetMobilePageType, pageInitialData);

            },
            GetTypeFromHash: function (typestr) {
                if (!JSLib.Mobile.PageLoader.RegisterMobilePages.containsKey(typestr)) {
                    return JSLib.Mobile.PageLoader.LoadPageType(typestr);
                } else {
                    return JSLib.Mobile.PageLoader.RegisterMobilePages.get(typestr);
                }
            }
        },
        PageType: null,
        PageInitialData: null,
        ctor: function (pageType, pageInitialData) {
            this.$initialize();
            this.PageType = pageType;
            this.PageInitialData = pageInitialData;
        },
        getHashString: function () {
            return JSLib.Mobile.MobilePage.GeneratePageId$1(this.PageType, this.PageInitialData);
        },
        Equals: function (targetObject) {
            if (Bridge.is(targetObject, String)) {
                return Bridge.referenceEquals(this.getHashString(), Bridge.cast(targetObject, String));
            }
            {
                return this.GetHashCode() === Bridge.getHashCode(targetObject);
            }
        },
        GetHashCode: function () {
            var page = System.String.replaceAll(Bridge.Reflection.getTypeFullName(this.PageType), ".", "-");
            var pageData = "";
            if (this.PageInitialData != null) {
                pageData = System.String.concat("--", JSON.stringify(this.PageInitialData));
            }
            var data = System.String.concat(page, pageData);
            return Bridge.getHashCode(data);
        },
        Clone: function () {
            return new JSLib.Mobile.PageData(this.PageType, this.PageInitialData);
        }
    });

    Bridge.define("JSLib.Mobile.PageInstanceData", {
        PageData: null,
        BasePage: null
    });

    Bridge.define("JSLib.Mobile.PageLoader", {
        statics: {
            RegisterMobilePages: null,
            config: {
                init: function () {
                    this.RegisterMobilePages = new (System.Collections.Generic.Dictionary$2(String,Function))();
                }
            },
            LoadPageType: function (pageTypeStr) {
                var resultType = null;
                var generatePageId = "";

                var baseNameSpaceLength = JSLib.Mobile.Application.getBaseNameSpace().length;
                //类似 "Navigation-Page1"
                var leftStr = pageTypeStr.substr(((baseNameSpaceLength + 1) | 0));
                //类似 "Navigation"
                var pageSpace = System.String.replaceAll(leftStr.substr(0, leftStr.lastIndexOf("-")), "-", "/");
                //类似 "Page1"
                var pageName = System.String.isNullOrEmpty(pageSpace) ? leftStr.substr(pageSpace.length) : leftStr.substr(((pageSpace.length + 1) | 0));

                //根据类型字符串中定位JS文件路径
                var pagePathWithoutExtension = System.String.concat(JSLib.Mobile.Application.RootPath, System.String.replaceAll(pageSpace, ".", "/"), "/", pageName);
                var jsFilePath = System.String.concat(pagePathWithoutExtension, ".js");
                if (!JSLib.Mobile.PageLoader.RegisterMobilePages.containsKey(pageTypeStr)) {
                    //同步加载Js文件，并获取运行时的页面类型
                    var result = $.ajax({ async: false, url: jsFilePath, dataType: "script", type: "get" });

                    if (System.String.isNullOrEmpty(result.responseText)) {
                        throw new System.Exception("页面内容为空！");
                    }
                    //加载的类型为最后一个程序集的第一个类型
                    resultType = Bridge.Reflection.getAssemblyTypes(System.Linq.Enumerable.from(System.AppDomain.getAssemblies()).last())[0];
                    if (resultType == null) {
                        return null;
                    }
                    generatePageId = JSLib.Mobile.MobilePage.GeneratePageId$1(resultType);
                    JSLib.Mobile.PageLoader.RegisterMobilePages.add(generatePageId, resultType);
                } else {
                    resultType = JSLib.Mobile.PageLoader.RegisterMobilePages.get(pageTypeStr);

                }
                return resultType;

            },
            LoadPageType$1: function (pageSpace, pageName) {
                var baseNameSpace = JSLib.Mobile.Application.getBaseNameSpace();
                if (!System.String.isNullOrEmpty(pageSpace)) {
                    baseNameSpace = System.String.concat(baseNameSpace, ".", pageSpace);
                }
                //判断页面类型是否已注册
                //如果未注册需要加载对应的JS文件
                var pagetypeStr = System.String.concat(System.String.replaceAll(baseNameSpace, ".", "-"), "-", pageName);
                var pagePathWithoutExtension = System.String.concat(JSLib.Mobile.Application.RootPath, System.String.replaceAll(pageSpace, ".", "/"), "/", pageName);
                if (!JSLib.Mobile.PageLoader.RegisterMobilePages.containsKey(pagetypeStr)) {
                    var jsPath = System.String.concat(pagePathWithoutExtension, ".js");
                    //同步加载Js文件，并获取运行时的页面类型
                    $.ajax({ async: false, url: jsPath, dataType: "script", type: "get" });
                    var type = Bridge.Reflection.getType(System.String.concat(baseNameSpace, ".", pageName), Bridge.Reflection.load(pageName));
                    JSLib.Mobile.PageLoader.RegisterMobilePages.add(JSLib.Mobile.MobilePage.GeneratePageId$1(type), type);
                    return type;
                } else {
                    var resultType = JSLib.Mobile.PageLoader.RegisterMobilePages.get(pagetypeStr);
                    return resultType;
                }
            },
            LoadCss: function (pageType) {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                //加载页面对应的CSS文件
                var generatePageId = JSLib.Mobile.MobilePage.GeneratePageId$1(pageType);
                var pagePathWithoutExtension = "";
                pagePathWithoutExtension = System.String.concat(JSLib.Mobile.Application.RootPath, System.String.replaceAll(Bridge.Reflection.getTypeFullName(pageType).substr(((JSLib.Mobile.Application.getBaseNameSpace().length + 1) | 0)), ".", "/"));
                var pageCSSSelector = System.String.format("link[data-type='{0}']", generatePageId);
                if ($(pageCSSSelector).length === 0) {
                    var cssPath = System.String.concat(pagePathWithoutExtension, ".css");
                    if (JSLib.Mobile.Application.LoadCssForce) {
                        cssPath = System.String.concat(cssPath, "?r=", System.Double.format(Math.random(), 'G'));
                    }
                    var styleEle = $(System.String.format("<link data-type='{0}' rel='stylesheet' href='{1}' />", generatePageId, cssPath));

                    styleEle.appendTo("head");
                    JSLib.Mobile.Application.SystemLog("----AuoLoadCSS CSS Append To Head");

                    var appendResult = false;
                    styleEle[0].onload = function (event) {
                        appendResult = true;
                        tsk.setResult(true);
                    };
                    styleEle[0].onerror = function (event, url, lineNumber, columnNumber, error) {
                        JSLib.Mobile.Application.SystemLog("----AuoLoadCSS Error");
                        appendResult = false;
                        tsk.setResult(false);
                        return true;
                    };
                    window.setTimeout(function () {
                        if (!appendResult) {
                            tsk.setResult(true);
                        }
                    }, 1000);

                } else {
                    tsk.setResult(true);
                }
                return tsk.task;
            }
        }
    });

    Bridge.define("JSLib.Mobile.PageResourceManager", {
        statics: {
            ctor: function () {
                window.setInterval(JSLib.Mobile.PageResourceManager.CheckAndReleasePage, 500000000);
            },
            MaxPageCount: 1,
            CheckAndReleasePage: function () {
                var $t;
                if (JSLib.Mobile.MobilePage.DomPageRepository.getCount() > JSLib.Mobile.PageResourceManager.MaxPageCount) {
                    var releaseCount = (JSLib.Mobile.MobilePage.DomPageRepository.getCount() - JSLib.Mobile.PageResourceManager.MaxPageCount) | 0;
                    var pages = System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).orderBy($asm.$.JSLib.Mobile.PageResourceManager.f1).take(releaseCount);
                    $t = Bridge.getEnumerator(pages);
                    while ($t.moveNext()) {
                        var page = $t.getCurrent();
                        page.BasePage.Destroy();
                    }
                }
            }
        }
    });

    Bridge.ns("JSLib.Mobile.PageResourceManager", $asm.$);

    Bridge.apply($asm.$.JSLib.Mobile.PageResourceManager, {
        f1: function (n) {
            return n.BasePage.LastShowDateTime;
        }
    });

    Bridge.define("JSLib.Mobile.PageTranslateAnimation", {
        $kind: "enum",
        statics: {
            Default: 0,
            No: 1
        }
    });

    Bridge.define("JSLib.Mobile.UserGeoLocation", {
        Lontitiude: 0,
        Latitude: 0,
        Address: null
    });

    Bridge.define("JSLib.Mobile.UserGeoLocationArgs", {
        LocationData: null
    });

    Bridge.define("JSLib.Oauth.SinaLogin", {
        statics: {
            isJSLoad: false,
            LoadSinaLoginJSSDK: function () {

            }
        }
    });

    Bridge.define("JSLib.Plus.PlusService", {
        statics: {
            WaitPlusReady: function () {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                document.addEventListener("plusready", function (n) {
                    tsk.setResult(true);
                });
                return tsk.task;
            },
            IsPlusEnv: function () {
                var $t;
                return ($t=window.navigator.userAgent, System.String.indexOf($t, "Html5Plus", 0, $t.length, 5)) !== -1;
            }
        }
    });

    Bridge.define("JSLib.ResourceManager.ResourceLoader", {
        LoadJS: function (jsPath, nameValues) {
            if (nameValues === void 0) { nameValues = []; }
            var tsk = new System.Threading.Tasks.TaskCompletionSource();
            this.GetScript(jsPath, function () {
                tsk.setResult(true);
            }, nameValues);
            return tsk.task;
        },
        GetScript: function (url, callBackAction, nameValues) {
            if (nameValues === void 0) { nameValues = []; }
            var script = document.createElement("script");
            script.async = true;
            script.src = url;
            if (!Bridge.staticEquals(callBackAction, null)) {
                script.onload = function (event) {
                    callBackAction();
                };
            }

            var scripttarget = $(script);
            if (nameValues != null && nameValues.length >= 2) {
                for (var i = 0; i < ((Bridge.Int.div(nameValues.length, 2)) | 0); i = (i + 2) | 0) {
                    scripttarget.attr(nameValues[i], nameValues[((i + 1) | 0)]);
                }
            }
            document.getElementsByTagName("head")[0].appendChild(script);
        }
    });

    Bridge.define("JSLib.SingleTask", {
        statics: {
            ctor: function () {
                JSLib.SingleTask.TaskList = new (System.Collections.Generic.List$1(Function))();
            },
            TaskList: null,
            IsRunning: false,
            Enquee: function (task) {
                if (JSLib.SingleTask.IsRunning) {
                    return;
                }
                if (JSLib.SingleTask.TaskList.contains(task)) {
                    return;
                }

                JSLib.SingleTask.TaskList.add(task);
                JSLib.SingleTask.Do();
            },
            Do: function () {
                var $step = 0,
                    $task1, 
                    $jumpFromFinally, 
                    firstTask, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3], $step);
                            switch ($step) {
                                case 0: {
                                    if ( !JSLib.SingleTask.IsRunning && JSLib.SingleTask.TaskList.getCount() > 0 ) {
                                            $step = 1;
                                            continue;
                                        } 
                                        $step = 3;
                                        continue;
                                }
                                case 1: {
                                    JSLib.SingleTask.IsRunning = true;
                                        firstTask = System.Linq.Enumerable.from(JSLib.SingleTask.TaskList).first();
                                        JSLib.SingleTask.TaskList.remove(firstTask);
                                        $task1 = firstTask();
                                        $step = 2;
                                        $task1.continueWith($asyncBody, true);
                                        return;
                                }
                                case 2: {
                                    $task1.getAwaitedResult();
                                    JSLib.SingleTask.IsRunning = false;

                                        $step = 0;
                                        continue;
                                }
                                case 3: {
                                    return;
                                }
                                default: {
                                    return;
                                }
                            }
                        }
                    }, arguments);

                $asyncBody();
            }
        }
    });

    Bridge.define("JSLib.TakePictureResult", {
        fileName: null,
        base64Data: null,
        getFileURIData: function () {
            return System.String.concat("data:image/x-jpeg;base64,", this.base64Data);
        }
    });

    Bridge.define("JSLib.TaskEx", {
        statics: {
            CancelSilently: function (task) {
                var tsk = task;
                if (tsk.onCancelSilently != null) {
                    tsk.onCancelSilently();
                }

            },
            OnCancelSilently: function (task, onCancelSilently) {
                task.onCancelSilently = onCancelSilently;
            }
        }
    });

    Bridge.define("JSLib.TaskQuee", {
        statics: {
            ctor: function () {
                JSLib.TaskQuee.TaskList = new (System.Collections.Generic.List$1(Function))();
            },
            TaskList: null,
            IsRunning: false,
            Enquee: function (task) {
                JSLib.TaskQuee.TaskList.add(task);
                JSLib.TaskQuee.Do();
            },
            Do: function () {
                var $step = 0,
                    $task1, 
                    $jumpFromFinally, 
                    curTask, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3], $step);
                            switch ($step) {
                                case 0: {
                                    if ( !JSLib.TaskQuee.IsRunning && JSLib.TaskQuee.TaskList.getCount() > 0 ) {
                                            $step = 1;
                                            continue;
                                        } 
                                        $step = 3;
                                        continue;
                                }
                                case 1: {
                                    JSLib.TaskQuee.IsRunning = true;
                                        curTask = System.Linq.Enumerable.from(JSLib.TaskQuee.TaskList).last();
                                        JSLib.TaskQuee.TaskList.remove(curTask);
                                        $task1 = curTask();
                                        $step = 2;
                                        $task1.continueWith($asyncBody, true);
                                        return;
                                }
                                case 2: {
                                    $task1.getAwaitedResult();
                                    JSLib.TaskQuee.IsRunning = false;

                                        $step = 0;
                                        continue;
                                }
                                case 3: {
                                    return;
                                }
                                default: {
                                    return;
                                }
                            }
                        }
                    }, arguments);

                $asyncBody();
            }
        }
    });

    Bridge.define("JSLib.Tool.CssGeter", {
        statics: {
            GetCssPath: function (element, parent, output) {
                var $t;
                if (parent === void 0) { parent = ""; }
                if (output === void 0) { output = true; }
                var data = new (System.Collections.Generic.List$1($))();

                var current = $(element);
                data.add(current);
                current.parentsUntil(".ui-page").each(function (index, element1) {
                    data.add($(element1));
                });
                var pageroot = current.parents(".ui-page");
                if (pageroot.length === 0) {
                    return "";
                }
                parent = pageroot.attr("class").split(String.fromCharCode(32))[0];

                var sb = new System.Text.StringBuilder();
                sb.append(".").append(parent);
                data.reverse();
                $t = Bridge.getEnumerator(data);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();

                    sb.append(" ");
                    if (!System.String.isNullOrEmpty(item.attr("id"))) {
                        sb.append("#").append(item.attr("id"));
                    } else if (!System.String.isNullOrEmpty(item.attr("class"))) {
                        sb.append(".").append(item.attr("class"));
                    } else {
                        sb.append(item[0].tagName);
                    }
                }
                sb.append("{}");
                if (output) {
                    console.info(sb.toString());
                }
                return sb.toString();

            },
            ListCssPath: function (element) {
                var $t;
                var current = $(element);
                var data = new (System.Collections.Generic.List$1(String))();
                JSLib.Tool.CssGeter.IterateItem(current, data);
                var sb = new System.Text.StringBuilder();
                $t = Bridge.getEnumerator(data);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    sb.appendLine(item);
                }
                console.info(sb.toString());
            },
            IterateItem: function (jQuery, data) {
                if (jQuery.length > 0) {
                    jQuery.each(function (index, element) {
                        data.add(JSLib.Tool.CssGeter.GetCssPath(element, "", false));
                    });
                    JSLib.Tool.CssGeter.IterateItem(jQuery.children(), data);
                }
            }
        }
    });

    Bridge.define("JSLib.UnionLogin.QQLogin", {
        statics: {
            QQAPPID: "101032040",
            isPreparedJs: false,
            PreapareJS: function () {
                var $step = 0,
                    $task1, 
                    $jumpFromFinally, 
                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                    $returnValue, 
                    $async_e, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        try {
                            for (;;) {
                                $step = System.Array.min([0,1], $step);
                                switch ($step) {
                                    case 0: {
                                        if (JSLib.UnionLogin.QQLogin.isPreparedJs) {
                                                $tcs.setResult(null);
                                                return;
                                            }
                                            $task1 = new JSLib.ResourceManager.ResourceLoader().LoadJS("http://qzonestyle.gtimg.cn/qzone/openapi/qc-1.0.1.js", ["data-appid", JSLib.UnionLogin.QQLogin.QQAPPID]);
                                            $step = 1;
                                            $task1.continueWith($asyncBody);
                                            return;
                                    }
                                    case 1: {
                                        $task1.getAwaitedResult();
                                        JSLib.UnionLogin.QQLogin.isPreparedJs = true;
                                        $tcs.setResult(null);
                                        return;
                                    }
                                    default: {
                                        $tcs.setResult(null);
                                        return;
                                    }
                                }
                            }
                        } catch($async_e1) {
                            $async_e = System.Exception.create($async_e1);
                            $tcs.setException($async_e);
                        }
                    }, arguments);

                $asyncBody();
                return $tcs.task;
            },
            GetUserInfo: function () {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                QC.Login.getMe(function (openId, accessToken) {
                        var url = System.String.format("https://graph.qq.com/user/get_user_info?oauth_consumer_key={0}&access_token={1}&openid={2}&format=json", JSLib.UnionLogin.QQLogin.QQAPPID, accessToken, openId);

                        var option = { url: url, success: function (data, status, request) {
                            tsk.setResult(Bridge.merge(Bridge.createInstance(JSLib.UnionLogin.QQUserInfo), JSON.parse(data)));
                        } };
                        $.ajax(option);
                    });
                return tsk.task;
            },
            ShowPopUp: function (redirectUrl, OnWindowClose) {
                if (OnWindowClose === void 0) { OnWindowClose = null; }
                var windower = QC.Login.showPopup({ appId: JSLib.UnionLogin.QQLogin.QQAPPID, redirectURI: redirectUrl });
                windower.addEventListener("beforeunload", function () {
                    !Bridge.staticEquals(OnWindowClose, null) ? OnWindowClose() : null;
                });
                return windower;
            },
            GetMe: function () {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                QC.Login.getMe(function (openId, accessToken) {
                        tsk.setResult(Bridge.merge(new JSLib.UnionLogin.QQLoignAccessInfo(), {
                            openId: openId,
                            accessToken: accessToken
                        } ));
                    });
                return tsk.task;
            }
        }
    });

    Bridge.define("JSLib.UnionLogin.QQLoignAccessInfo", {
        openId: null,
        accessToken: null
    });

    Bridge.define("JSLib.Util.IsScrollExtension", {
        statics: {
            CheckRefresh: function (iscroll) {
                if (iscroll == null) {
                    return;
                }
                var check = iscroll.scrollerH !== iscroll.scroller.offsetHeight || iscroll.scrollerW !== iscroll.scroller.offsetWidth;
                if (check) {
                    iscroll.wrapperH = iscroll.wrapper.clientHeight;
                    iscroll.scrollerW = iscroll.scroller.offsetWidth;
                    iscroll.scrollerH = (iscroll.scroller.offsetHeight + iscroll.minScrollY) | 0;
                    iscroll.maxScrollX = (iscroll.wrapperW - iscroll.scrollerW) | 0;
                    iscroll.maxScrollY = (((iscroll.wrapperH - iscroll.scrollerH) | 0) + iscroll.minScrollY) | 0;
                }
            }
        }
    });

    Bridge.define("JSLib.Util.SizeCalculator", {
        statics: {
            GetLeftHeight: function (data) {
                var $t;
                if (data === void 0) { data = []; }
                var totalHeight = 0;
                $t = Bridge.getEnumerator(data);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    totalHeight = (totalHeight + (item.outerHeight(true))) | 0;
                }
                return ((window.innerHeight - totalHeight) | 0);
            }
        }
    });

    Bridge.define("JSLib.Util.URL", {
        statics: {
            GetParamValue: function (paramName, queryString) {
                var $t;
                if (queryString === void 0) { queryString = ""; }

                var query = "";
                if (!System.String.isNullOrEmpty(queryString)) {
                    query = queryString;
                } else {
                    query = window.location.search.substr(1);
                }
                var vars = query.split(String.fromCharCode(38));
                $t = Bridge.getEnumerator(vars);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    var pair = item.split(String.fromCharCode(61));
                    if (Bridge.referenceEquals(decodeURIComponent(pair[0]), paramName)) {
                        return decodeURIComponent(pair[1]);
                    }
                }
                return "";
            },
            GetAllExceptHash: function (url) {
                if (url === void 0) { url = ""; }
                var href = window.location.href;
                if (!System.String.isNullOrEmpty(url)) {
                    href = url;
                }
                var lastSharpIndex = href.lastIndexOf("#");
                var resultStr = "";
                if (lastSharpIndex !== -1) {
                    resultStr = href.substring(0, lastSharpIndex);
                } else {
                    resultStr = href;
                }
                return resultStr;
            }
        }
    });

    Bridge.define("JSLib.WebData", {
        statics: {
            dataBaseUrl: null,
            SetupDataUrl: function (baseUrl) {
                JSLib.WebData.dataBaseUrl = baseUrl;
            },
            PostData: function (data, successCallaback, showLoading, url, isGet, OnComplete, showConnectionError, errorCallBack, requestContentType) {
                var $t;
                if (successCallaback === void 0) { successCallaback = null; }
                if (showLoading === void 0) { showLoading = false; }
                if (url === void 0) { url = null; }
                if (isGet === void 0) { isGet = true; }
                if (OnComplete === void 0) { OnComplete = null; }
                if (showConnectionError === void 0) { showConnectionError = true; }
                if (errorCallBack === void 0) { errorCallBack = null; }
                if (requestContentType === void 0) { requestContentType = "application/x-www-form-urlencoded;charset=utf-8"; }
                var postUrl = ($t = url, $t != null ? $t : JSLib.WebData.dataBaseUrl);
                //if (data != null)
                //{
                //    postUrl = postUrl + "?" + data;
                //}
                var option = { url: postUrl, data: data, async: true, type: isGet ? "get" : "post", timeout: JSLib.Mobile.Application.WebRequestTimeOut, contentType: requestContentType };


                if (showLoading) {
                    JSLib.Mobile.Application.ShowLoading();
                }

                option.success = function (responsedata, textStatus, jqueryrequest) {
                    if (showLoading) {
                        JSLib.Mobile.Application.HideLoading();
                    }
                    !Bridge.staticEquals(successCallaback, null) ? successCallaback(responsedata) : null;
                };
                option.error = function (jqueryrequest, textStatus, error) {
                    if (showLoading) {
                        JSLib.Mobile.Application.HideLoading();
                    }

                    if (showConnectionError) {
                        JSLib.Mobile.MessageBox.Alert(error != null ? "网络连接出现错误！" : "网络不给力！");
                    }
                    !Bridge.staticEquals(errorCallBack, null) ? errorCallBack() : null;
                };
                if (!Bridge.staticEquals(OnComplete, null)) {
                    option.complete = function () {
                        OnComplete();
                    };
                }
                $.ajax(option);

            },
            PostDataTask: function (T, data, showLoading, url, isGet, useCache, requestContentType, errorCallBack, page) {
                if (showLoading === void 0) { showLoading = false; }
                if (url === void 0) { url = null; }
                if (isGet === void 0) { isGet = true; }
                if (useCache === void 0) { useCache = true; }
                if (requestContentType === void 0) { requestContentType = "application/x-www-form-urlencoded;charset=utf-8"; }
                if (errorCallBack === void 0) { errorCallBack = null; }
                if (page === void 0) { page = null; }
                return JSLib.WebData.PostDataTaskCompletionSource(T, data, showLoading, url, isGet, useCache, requestContentType, errorCallBack, page).task;
            },
            PostDataTaskCompletionSource: function (T, data, showLoading, url, isGet, useCache, requestContentType, errorCallBack, page) {
                var $t;
                if (showLoading === void 0) { showLoading = false; }
                if (url === void 0) { url = null; }
                if (isGet === void 0) { isGet = true; }
                if (useCache === void 0) { useCache = true; }
                if (requestContentType === void 0) { requestContentType = "application/x-www-form-urlencoded;charset=utf-8"; }
                if (errorCallBack === void 0) { errorCallBack = null; }
                if (page === void 0) { page = null; }
                var task = new System.Threading.Tasks.TaskCompletionSource();

                var option = { url: ($t = url, $t != null ? $t : JSLib.WebData.dataBaseUrl), async: true, data: data, type: isGet ? "get" : "post", timeout: JSLib.Mobile.Application.WebRequestTimeOut, contentType: requestContentType, cache: useCache };

                System.Threading.Tasks.Task.run(function () {
                    var $step = 0,
                        $task1, 
                        $taskResult1, 
                        $jumpFromFinally, 
                        $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                        $returnValue, 
                        loadingDialog, 
                        request, 
                        $async_e, 
                        $asyncBody = Bridge.fn.bind(this, function () {
                            try {
                                for (;;) {
                                    $step = System.Array.min([0,1,2,3], $step);
                                    switch ($step) {
                                        case 0: {
                                            loadingDialog = null;
                                                if (showLoading && page != null) {
                                                    $step = 1;
                                                    continue;
                                                } 
                                                $step = 3;
                                                continue;
                                        }
                                        case 1: {
                                            $task1 = page.ShowLoading();
                                                $step = 2;
                                                $task1.continueWith($asyncBody);
                                                return;
                                        }
                                        case 2: {
                                            $taskResult1 = $task1.getAwaitedResult();
                                            loadingDialog = $taskResult1;
                                            $step = 3;
                                            continue;
                                        }
                                        case 3: {
                                            option.success = function (responsedata, textStatus, jqueryrequest) {
                                                    if (showLoading && loadingDialog != null) {
                                                        if (JSLib.Mobile.Application.EnableSystemLog) {
                                                            console.log("移除Loading!");
                                                        }
                                                        loadingDialog.Destroy();
                                                    }
                                                    try {
                                                        var result = Bridge.merge(Bridge.createInstance(T), JSON.parse(jqueryrequest.responseText));
                                                        task.trySetResult(result);
                                                    }
                                                    catch (ex) {
                                                        ex = System.Exception.create(ex);
                                                        task.setException(ex);
                                                    }

                                                };
                                                option.error = function (jqueryrequest, textStatus, error) {
                                                    if (showLoading && loadingDialog != null) {
                                                        if (JSLib.Mobile.Application.EnableSystemLog) {
                                                            console.log("移除Loading!");
                                                        }
                                                        loadingDialog.Destroy();
                                                    }
                                                    if (jqueryrequest.statusText == 'abort') {
                                                        return;
                                                    }
                                                    var result = Bridge.getDefaultValue(T);
                                                    if (!Bridge.staticEquals(errorCallBack, null)) {
                                                        result = errorCallBack(jqueryrequest, textStatus, new System.Exception(error));
                                                    }
                                                    task.setResult(result);
                                                    //MessageBox.Alert(!string.IsNullOrEmpty(error.As<string>()) ? "服务端出现异常【" + error
                                                    //    + "】！" : "网络不给力或无法连接服务端！");
                                                };
                                                request = $.ajax(option);
                                                JSLib.TaskEx.OnCancelSilently(task.task, function () {
                                                    request.abort();
                                                });
                                            $tcs.setResult(null);
                                            return;
                                        }
                                        default: {
                                            $tcs.setResult(null);
                                            return;
                                        }
                                    }
                                }
                            } catch($async_e1) {
                                $async_e = System.Exception.create($async_e1);
                                $tcs.setException($async_e);
                            }
                        }, arguments);

                    $asyncBody();
                    return $tcs.task;
                });

                return task;
            },
            PostDataSync: function (T, data, url, isGet, reuqestContentType) {
                var $t;
                if (url === void 0) { url = null; }
                if (isGet === void 0) { isGet = true; }
                if (reuqestContentType === void 0) { reuqestContentType = "application/x-www-form-urlencoded;charset=utf-8"; }

                var option = { url: ($t = url, $t != null ? $t : JSLib.WebData.dataBaseUrl), async: false, data: data, type: isGet ? "get" : "post", timeout: JSLib.Mobile.Application.WebRequestTimeOut, contentType: reuqestContentType };


                option.error = $asm.$.JSLib.WebData.f1;
                var request = $.ajax(option);
                return Bridge.merge(Bridge.createInstance(T), JSON.parse(request.responseText));
            },
            GetScript: function (url, callBackAction) {
                if (callBackAction === void 0) { callBackAction = null; }
                var script = document.createElement("script");
                script.async = false;
                script.src = url;
                if (!Bridge.staticEquals(callBackAction, null)) {
                    script.onload = function (event) {
                        callBackAction();
                    };

                }
                document.getElementsByTagName("head")[0].appendChild(script);
            },
            GetScriptTask: function (url) {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                JSLib.WebData.GetScript(url, function () {
                    tsk.setResult(true);
                });
                return tsk.task;
            }
        }
    });

    Bridge.ns("JSLib.WebData", $asm.$);

    Bridge.apply($asm.$.JSLib.WebData, {
        f1: function (jqueryrequest, textStatus, error) {
            JSLib.Mobile.MessageBox.Alert(error != null ? "网络连接出现错误！" : "网络不给力！");
        }
    });

    Bridge.define("JSLib.Widget.BackArgs", {
        IsContinueGoBack: false
    });

    Bridge.define("JSLib.Widget.Behavior.SortableBehavior", {
        statics: {
            Sortable: function (parentContainer, childItemSelector) {
                if (childItemSelector === void 0) { childItemSelector = ""; }
                if (System.String.isNullOrEmpty(childItemSelector)) {
                    childItemSelector = ">*";
                }
                var currentDraging = null;

                //克隆一个子元素，用作占位符
                var simpleChildItem = $(parentContainer.children()[0]);
                var placeHolder = simpleChildItem.clone().empty();
                window.setTimeout(function () {
                    placeHolder.height(simpleChildItem.height());
                }, 500);

                placeHolder.addClass("c-sortableplaceholder");

                parentContainer.on("dragstart", childItemSelector, function (event) {
                    if (currentDraging != null) {
                        return;
                    }
                    var dataTransfer = event.originalEvent.dataTransfer;
                    dataTransfer.effectAllowed = "copymove";
                    dataTransfer.dropEffect = "copy";
                    currentDraging = $(event.currentTarget);
                    currentDraging.after(placeHolder);
                    placeHolder.show();
                });

                parentContainer.on("dragover", childItemSelector, function (event) {
                    event.preventDefault();
                    if (currentDraging != null) {
                        currentDraging.hide();
                        var target = $(event.currentTarget);
                        if (!Bridge.referenceEquals(target, placeHolder)) {
                            if (placeHolder.index() < target.index()) {
                                target.after(placeHolder);
                            } else {
                                target.before(placeHolder);
                            }
                        }
                    }
                });

                parentContainer.on("drop dragend", childItemSelector, function (event) {
                    if (currentDraging != null) {
                        placeHolder.before(currentDraging);
                        placeHolder.detach().hide();
                        currentDraging.show();
                        currentDraging = null;
                    }
                });

                return parentContainer;
            }
        }
    });

    Bridge.define("JSLib.Widget.IBackEvent", {
        $kind: "interface"
    });

    Bridge.define("JSLib.Widget.Common.DateRange", {
        BeginDate: null,
        EndDate: null,
        MinDate: null,
        MaxDate: null
    });

    Bridge.define("JSLib.Widget.Common.DateTimeTarget", {
        _MaxDate: null,
        _MinDate: null,
        _defaultDate: null,
        ShowDate: true,
        ShowTime: false,
        EnalbeClean: true,
        config: {
            init: function () {
                this._defaultDate = new Date();
            }
        },
        getDefaultDate: function () {
            if (Bridge.Date.gt(this._defaultDate, this.getMaxDate())) {
                this._defaultDate = this.getMaxDate();
            }
            if (Bridge.Date.lt(this._defaultDate, this.getMinDate())) {
                this._defaultDate = this.getMinDate();
            }
            return this._defaultDate;
        },
        setDefaultDate: function (value) {
            if (Bridge.equals(value, null) || isNaN(System.Nullable.getValue(value))) {
                this._defaultDate = new Date();
            } else {
                this._defaultDate = value;
            }
        },
        getMaxDate: function () {
            if (Bridge.equals(this._MaxDate, null)) {
                return new Date(2999, 1 - 1, 1);
            }
            return this._MaxDate;
        },
        getMinDate: function () {
            if (Bridge.equals(this._MinDate, null)) {
                return new Date(1, 1 - 1, 1);
            }
            return this._MinDate;

        }
    });

    Bridge.define("JSLib.Widget.SwipeView.SwipeView", {
        target: null,
        snapThreshold: 80,
        lblMessage: null,
        _showLoadingMessage: false,
        config: {
            events: {
                OnSwipeThredEnd: null
            }
        },
        ctor: function (target, showLoadingMessage) {
            if (showLoadingMessage === void 0) { showLoadingMessage = false; }

            this.$initialize();
            this.target = target;

            var startX = 0;
            var startY = 0;
            var currentX = 0;
            var currentY = 0;
            var endX = 0;
            var endY = 0;
            var deltaX = 0;
            var deltaY = 0;
            var isStart = false;

            var lblMessage = null;
            this._showLoadingMessage = showLoadingMessage;

            if (this._showLoadingMessage) {
                lblMessage = $("<div style='position:absolute;top:20px;left:20px;z-index:2;background-color:black;color:white;padding:8px;'>松开即加载下一页</div>").appendTo(JSLib.Mobile.MobilePage.PageContainer).hide();
            }


            target.on("touchstart", Bridge.fn.bind(this, function (event) {
                isStart = true;
                this.target.get(0).style.setwebkitTransitionDuration("0ms");
                startX = event.originalEvent.touches[0].pageX;
                startY = event.originalEvent.touches[0].pageY;

            }));
            target.on("touchmove", Bridge.fn.bind(this, function (event) {
                if (!isStart) {
                    return;
                }
                currentX = event.originalEvent.touches[0].pageX;
                currentY = event.originalEvent.touches[0].pageY;

                deltaX = (currentX - startX) | 0;
                deltaY = (currentY - startY) | 0;
                if (Math.abs(deltaX) < Math.abs(deltaY)) {
                    isStart = false;
                    return;
                }
                this.pos(deltaX);


                if (this._showLoadingMessage) {
                    if (Math.abs(deltaX) >= this.snapThreshold) {
                        if (deltaX > 0) {
                            lblMessage.text("松开即加载上一页");
                        } else {
                            lblMessage.text("松开即加载下一页");
                        }
                        lblMessage.show();
                    } else {
                        lblMessage.hide();
                    }
                }

            }));
            target.on("touchend", Bridge.fn.bind(this, function (event) {
                if (!isStart) {
                    return;
                }
                if (this._showLoadingMessage) {
                    lblMessage.hide();
                }

                endX = event.originalEvent.changedTouches[0].pageX;
                deltaX = (endX - startX) | 0;

                this.target.get(0).style.setwebkitTransitionDuration("500ms");
                if (Math.abs(deltaX) < this.snapThreshold) {
                    startX = 0;
                    isStart = false;

                    this.pos(0);
                } else {
                    startX = 0;
                    isStart = false;
                    this.target.get(0).style.setwebkitTransitionDuration("0ms");
                    this.pos(0);
                    if (!Bridge.staticEquals(this.OnSwipeThredEnd, null)) {
                        this.OnSwipeThredEnd(this, Bridge.merge(new JSLib.Widget.SwipeView.SwipViewEventArgs(), {
                            swipViewDirection: deltaX > 0 ? JSLib.Widget.SwipeView.SwipViewDirection.Left : JSLib.Widget.SwipeView.SwipViewDirection.Right
                        } ));
                        if (this._showLoadingMessage) {
                            this.lblMessage = lblMessage.text("正在加载数据...").show();
                            System.Threading.Tasks.Task.run(function () {
                                var $step = 0,
                                    $task1, 
                                    $task2, 
                                    $jumpFromFinally, 
                                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                                    $returnValue, 
                                    $async_e, 
                                    $asyncBody = Bridge.fn.bind(this, function () {
                                        try {
                                            for (;;) {
                                                $step = System.Array.min([0,1,2], $step);
                                                switch ($step) {
                                                    case 0: {
                                                        $task1 = System.Threading.Tasks.Task.delay(2000);
                                                            $step = 1;
                                                            $task1.continueWith($asyncBody);
                                                            return;
                                                    }
                                                    case 1: {
                                                        $task1.getAwaitedResult();
                                                        lblMessage.hide(1000);
                                                            $task2 = System.Threading.Tasks.Task.delay(1000);
                                                            $step = 2;
                                                            $task2.continueWith($asyncBody);
                                                            return;
                                                    }
                                                    case 2: {
                                                        $task2.getAwaitedResult();
                                                        $tcs.setResult(null);
                                                        return;
                                                    }
                                                    default: {
                                                        $tcs.setResult(null);
                                                        return;
                                                    }
                                                }
                                            }
                                        } catch($async_e1) {
                                            $async_e = System.Exception.create($async_e1);
                                            $tcs.setException($async_e);
                                        }
                                    }, arguments);

                                $asyncBody();
                                return $tcs.task;
                            });
                        }

                    }
                }


            }));
        },
        pos: function (x) {
            this.target[0].style.setwebkitTransform("translate3d(" + x + "px,0,0)");
        },
        HideTip: function () {
            this.lblMessage != null ? this.lblMessage.hide() : null;
        }
    });

    Bridge.define("JSLib.Widget.SwipeView.SwipViewDirection", {
        $kind: "enum",
        statics: {
            Left: 1,
            Right: 2
        }
    });

    Bridge.define("JSLib.Widget.SwipeView.SwipViewEventArgs", {
        swipViewDirection: 0
    });

    Bridge.define("JSLib.Widget.ViewPager.FixedInfiniteQuee$1", function (T) { return {
        getData: null,
        havePrefetechData: null,
        data: null,
        MaxLength: 3,
        curPos: 0,
        config: {
            events: {
                OnItemRemove: null,
                OnItemAdd: null,
                OnItemSet: null,
                OnCurrentDataChange: null,
                OnCurPosChange: null
            },
            init: function () {
                this.data = new (System.Collections.Generic.List$1(T))();
            }
        },
        ctor: function (getData, havePrefetechData, maxLength) {
            if (maxLength === void 0) { maxLength = 3; }

            this.$initialize();
            this.getData = getData;
            this.MaxLength = maxLength;
            this.havePrefetechData = havePrefetechData;

        },
        getItem: function (index) {
            return this.data.getItem(index);
        },
        InlitialData: function () {
            var $step = 0,
                $task1, 
                $taskResult1, 
                $task2, 
                $taskResult2, 
                $task3, 
                $taskResult3, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                inlitialData, 
                rightData, 
                leftData, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3], $step);
                            switch ($step) {
                                case 0: {
                                    //添加初始数据
                                        $task1 = this.getData(Bridge.getDefaultValue(T), JSLib.Data.GestureDirection.RightToLeft);
                                        $step = 1;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 1: {
                                    $taskResult1 = $task1.getAwaitedResult();
                                    inlitialData = $taskResult1;
                                        this.Add(inlitialData, JSLib.Data.GestureDirection.RightToLeft);

                                        //尝试向左或向右各添加一条数据
                                        $task2 = this.getData(inlitialData, JSLib.Data.GestureDirection.RightToLeft);
                                        $step = 2;
                                        $task2.continueWith($asyncBody);
                                        return;
                                }
                                case 2: {
                                    $taskResult2 = $task2.getAwaitedResult();
                                    rightData = $taskResult2;
                                        if (rightData != null) {
                                            this.Add(rightData, JSLib.Data.GestureDirection.RightToLeft);
                                        }
                                        $task3 = this.getData(inlitialData, JSLib.Data.GestureDirection.LeftToRight);
                                        $step = 3;
                                        $task3.continueWith($asyncBody);
                                        return;
                                }
                                case 3: {
                                    $taskResult3 = $task3.getAwaitedResult();
                                    leftData = $taskResult3;
                                        if (leftData != null) {
                                            this.Add(leftData, JSLib.Data.GestureDirection.LeftToRight);
                                            this.curPos = (this.curPos + 1) | 0;
                                        }
                                        !Bridge.staticEquals(this.OnCurrentDataChange, null) ? this.OnCurrentDataChange(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs(T))(), {
                                                Data: inlitialData,
                                                gestureDirection: JSLib.Data.GestureDirection.RightToLeft
                                            } )) : null;
                                        !Bridge.staticEquals(this.OnCurPosChange, null) ? this.OnCurPosChange(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs(T))(), {
                                                Data: inlitialData,
                                                gestureDirection: JSLib.Data.GestureDirection.RightToLeft
                                            } )) : null;
                                    $tcs.setResult(null);
                                    return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        Add: function (target, gestureDirection) {
            if (gestureDirection === void 0) { gestureDirection = 1; }
            var isRemovedData = false;

            //如果当前暂存数据已达到定义的最大大小，则移除反向方向的末端数据
            if (this.data.getCount() >= this.MaxLength) {
                var removed;
                var removedIndex = gestureDirection === JSLib.Data.GestureDirection.RightToLeft ? 0 : ((this.data.getCount() - 1) | 0);
                removed = this.data.getItem(removedIndex);
                this.data.removeAt(removedIndex);
                !Bridge.staticEquals(this.OnItemRemove, null) ? this.OnItemRemove(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs(T))(), {
                        Data: removed,
                        gestureDirection: gestureDirection === JSLib.Data.GestureDirection.RightToLeft ? JSLib.Data.GestureDirection.LeftToRight : JSLib.Data.GestureDirection.RightToLeft
                    } )) : null;
                isRemovedData = true;
            }

            if (gestureDirection === JSLib.Data.GestureDirection.RightToLeft) {
                this.data.add(target);
                !Bridge.staticEquals(this.OnItemAdd, null) ? this.OnItemAdd(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs(T))(), {
                        Data: target,
                        gestureDirection: JSLib.Data.GestureDirection.RightToLeft
                    } )) : null;
            } else {
                this.data.insert(0, target);
                !Bridge.staticEquals(this.OnItemAdd, null) ? this.OnItemAdd(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs(T))(), {
                        Data: target,
                        gestureDirection: JSLib.Data.GestureDirection.LeftToRight
                    } )) : null;
            }
            return isRemovedData;
        },
        MoveStep: function (gestureDirection) {
            //如果已到末端,则取消移动操作
            var isEnd = gestureDirection === JSLib.Data.GestureDirection.RightToLeft ? this.curPos === ((this.data.getCount() - 1) | 0) : this.curPos === 0;
            if (isEnd) {
                return false;
            }


            //当前位置为紧邻末端一条数据时，预先加载该末端数据
            var isNearEnd = gestureDirection === JSLib.Data.GestureDirection.RightToLeft ? this.curPos === ((this.data.getCount() - 2) | 0) : this.curPos === 1;

            //左边是否添加元素
            var isLeftAdd = false;
            var isAddAndReverseRemoved = false;
            var isAddData = false;
            if (isNearEnd) {
                var endIndex = gestureDirection === JSLib.Data.GestureDirection.RightToLeft ? ((this.data.getCount() - 1) | 0) : 0;
                try {
                    isAddData = this.havePrefetechData(this.data.getItem(endIndex), gestureDirection);
                }
                catch (ex) {
                    ex = System.Exception.create(ex);
                    return false;
                }
                if (isAddData) {
                    var index = endIndex;
                    var temptarget = this.data.getItem(endIndex);
                    isAddAndReverseRemoved = this.Add(Bridge.getDefaultValue(T), gestureDirection);

                    System.Threading.Tasks.Task.run(Bridge.fn.bind(this, function () {
                        var $step = 0,
                            $task1, 
                            $taskResult1, 
                            $jumpFromFinally, 
                            $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                            $returnValue, 
                            getedDataItem, 
                            $async_e, 
                            $asyncBody = Bridge.fn.bind(this, function () {
                                try {
                                    for (;;) {
                                        $step = System.Array.min([0,1], $step);
                                        switch ($step) {
                                            case 0: {
                                                $task1 = this.getData(temptarget, gestureDirection);
                                                    $step = 1;
                                                    $task1.continueWith($asyncBody);
                                                    return;
                                            }
                                            case 1: {
                                                $taskResult1 = $task1.getAwaitedResult();
                                                getedDataItem = $taskResult1;
                                                    if (getedDataItem != null) {
                                                        if (!isAddAndReverseRemoved && gestureDirection === JSLib.Data.GestureDirection.RightToLeft) {
                                                            this.SetData(((index + 1) | 0), getedDataItem);
                                                        } else {
                                                            this.SetData(index, getedDataItem);
                                                        }
                                                    }
                                                $tcs.setResult(null);
                                                return;
                                            }
                                            default: {
                                                $tcs.setResult(null);
                                                return;
                                            }
                                        }
                                    }
                                } catch($async_e1) {
                                    $async_e = System.Exception.create($async_e1);
                                    $tcs.setException($async_e);
                                }
                            }, arguments);

                        $asyncBody();
                        return $tcs.task;
                    }));
                }

            }

            if (gestureDirection === JSLib.Data.GestureDirection.RightToLeft) {
                this.curPos = (this.curPos + 1) | 0;
            } else {
                this.curPos = (this.curPos - 1) | 0;
            }

            //左边添加数据
            if (gestureDirection === JSLib.Data.GestureDirection.LeftToRight && isAddData) {
                this.curPos = (this.curPos + 1) | 0;
            }
            //左边减少数据
            if (isAddAndReverseRemoved && gestureDirection === JSLib.Data.GestureDirection.RightToLeft) {
                this.curPos = (this.curPos - 1) | 0;
            }


            if (!Bridge.staticEquals(this.OnCurPosChange, null)) {
                this.OnCurPosChange(null, null);
            }

            //触发事件
            if (!Bridge.staticEquals(this.OnCurrentDataChange, null)) {
                this.OnCurrentDataChange(this, Bridge.merge(new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs(T))(), {
                    Data: this.data.getItem(this.curPos),
                    gestureDirection: gestureDirection
                } ));
            }
            //PrintData();

            return true;
        },
        SetData: function (index, getedDataItem) {
            this.data.setItem(index, getedDataItem);
            if (!Bridge.staticEquals(this.OnItemSet, null)) {
                this.OnItemSet(null, Bridge.merge(new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs(T))(), {
                    index: index,
                    Data: getedDataItem
                } ));
            }
        },
        PrintData: function () {
            var $t;
            console.info("--开始打印数据:");
            $t = Bridge.getEnumerator(this.data);
            while ($t.moveNext()) {
                var item = $t.getCurrent();
                console.log(item);
            }
            console.info("--当前数据:");
            console.log(this.data.getItem(this.curPos));
            console.info("--结束打印数据");
        }
    }; });

    Bridge.define("JSLib.Widget.ViewPager.FixedInfiniteQuee$1.ItemArgs", function (T) { return {
        index: 0,
        Data: Bridge.getDefaultValue(T),
        gestureDirection: 0
    }; });

    Bridge.define("JSLib.Widget.ViewPager.FixedLengthDictionary$2.ItemArgs", function (TKey, TValue) { return {
        IsTail: false,
        key: Bridge.getDefaultValue(TKey),
        value: Bridge.getDefaultValue(TValue)
    }; });

    Bridge.define("JSLib.Widget.ViewPager.IViewPagerItem", {
        $kind: "interface"
    });

    Bridge.define("JSLib.Widget.ViewPager.PageChanged$1", function (T) { return {
        Data: Bridge.getDefaultValue(T)
    }; });

    Bridge.define("ObjectEx", {
        statics: {
            ToJson: function (target) {
                if (target == null) {
                    return "";
                }
                return JSON.stringify(target);
            },
            FromJson: function (T, target) {
                if (System.String.isNullOrEmpty(target)) {
                    return Bridge.getDefaultValue(T);
                }
                return Bridge.merge(Bridge.createInstance(T), JSON.parse(target));
            },
            Base64EncodeWithJsonData: function (target) {
                if (target == null) {
                    return "";
                }
                return JSLib.CommonService.GetString(System.Convert.fromBase64String(ObjectEx.ToJson(target)));
            },
            Base64DecodeWithJsonData: function (T, target) {
                if (System.String.isNullOrEmpty(target)) {
                    return Bridge.getDefaultValue(T);
                }
                return ObjectEx.FromJson(T, JSLib.CommonService.GetString(System.Convert.fromBase64String(target)));
            },
            $Length: function (T, target) {
                return target.length;
            },
            AsRealType: function (T, target) {
                return Bridge.cast(target, T);
            },
            Clone: function (T, listToClone) {
                return System.Linq.Enumerable.from(listToClone).select(function (item) {
                        return CoreEx.CloneBySerilization(T, item);
                    }).toList(T);
            }
        }
    });

    Bridge.define("ObjExtension", {
        statics: {
            JoinWith: function (args, separator) {
                if (args == null) {
                    return "";
                }
                ;
                return args.join(separator);
            },
            EnsureNotNull: function (T, args) {
                if (args == null) {
                    return [];
                }
                return args;
            },
            WithEnclosingQuotation: function (target) {
                if (target == null) {
                    return null;
                }
                return System.String.format("\"{0}\"", target);
            },
            BufferToString: function (target) {
                if (target == null) {
                    return "";
                }
                var encoding = "";
                if (Bridge.referenceEquals(window.navigator.platform, "MacIntel")) {
                    encoding = "UTF8";
                } else {
                    encoding = "GBK";
                }
                var result = require('iconv-lite').decode(target, encoding);
                return result;
            }
        }
    });

    Bridge.define("StringHelper", {
        statics: {
            ToNatureTime: function (datetime) {
                var now = new Date();
                var timespan = new System.TimeSpan(StringHelper.GetTicks(now).sub(StringHelper.GetTicks(datetime)));
                var result = "";
                if (timespan.getDays() > 2) {
                    result = System.String.format("{0}天前", timespan.getDays());
                } else if (timespan.getDays() > 1) {
                    result = System.String.format("昨天", null);
                } else if (timespan.getHours() > 1) {
                    result = System.String.format("{0}小时前", timespan.getHours());
                } else if (timespan.getMinutes() > 1) {
                    result = System.String.format("{0}分钟前", timespan.getMinutes());
                } else {
                    result = System.String.format("刚刚", null);
                }
                return result;
            },
            GetTicks: function (dateTime) {
                // the number of .net ticks at the unix epoch
                var epochTicks = System.Int64([-139100160,144670709]);

                // there are 10000 .net ticks per millisecond
                var ticksPerMillisecond = 10000;

                // calculate the total number of .net ticks for your date
                var ticks = epochTicks.add((System.Int64((dateTime).getTime()).mul(System.Int64(ticksPerMillisecond))));
                return ticks;
            },
            FormatBRToHtml: function (target) {
                if (System.String.isNullOrEmpty(target)) {
                    return target;
                }
                var result = System.String.replaceAll(System.String.replaceAll(System.String.replaceAll(System.String.replaceAll(target, "\r\n", "<br/>"), "\n\r", "<br/>"), "\r", "<br/>"), "\n", "<br/>");
                result = System.String.replaceAll(result, "<br>", "<br/>");
                for (var i = 0; i < 6; i = (i + 1) | 0) {
                    result = System.String.replaceAll(result, "<br/><br/>", "<br/>");
                }
                return result;
            },
            GetLeftTime: function (target) {
                return Bridge.Date.subdd(target, new Date());
            },
            WithDefault: function (target, defaultValue) {
                if (System.String.isNullOrEmpty(target)) {
                    return defaultValue;
                } else {
                    return target;
                }
            },
            RemoveEndStr: function (target, endStr) {
                if (System.String.endsWith(target, endStr)) {
                    return System.String.remove(target, target.lastIndexOf(endStr), endStr.length);
                } else {
                    return target;
                }
            },
            WithBase64ImageHeader: function (target) {
                return System.String.concat("data:image/png;charset=utf-8;base64,", target);
            },
            RemoveBase64Header: function (target) {
                if (System.String.contains(target,",")) {
                    var data = target.split(String.fromCharCode(44));
                    return data[1];
                }
                return target;
            }
        }
    });

    Bridge.define("System.Web.WebPages.HelperResult", {
        sb: null,
        config: {
            init: function () {
                this.sb = new System.Text.StringBuilder();
            }
        },
        ctor: function (action) {
            this.$initialize();
            action(this.sb);
        },
        toString: function () {
            return this.sb.toString();
        }
    });

    Bridge.define("UEExtension", {
        statics: {
            WaitReadyComplete: function (ue) {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();

                ue.ready(function () {
                    tsk.setResult(null);
                });

                return tsk.task;
            }
        }
    });

    Bridge.define("UIDataEx", {
        statics: {
            GetBindData: function (T, ele) {
                var result = UIDataEx.GetElementBindData(ele);
                return result;
            },
            GetBindData$1: function (T, ele) {
                return UIDataEx.GetBindData(T, ele.get(0));
            },
            GetElementBindData: function (ele) {
                if (ele == null) {
                    return null;
                }
                var bindid = $(ele).attr("data-c-bindid");
                if (System.String.isNullOrEmpty(bindid)) {
                    return null;
                }
                var bindData = System.Linq.Enumerable.from(JSLib.Data.DataBindHelper.bindDatas).selectMany($asm.$.UIDataEx.f1).firstOrDefault(function (n) {
                        return Bridge.referenceEquals(n.bindId, bindid);
                    }, null);
                if (bindData == null) {
                    return null;
                }
                var result = bindData.data;
                return result;
            }
        }
    });

    Bridge.ns("UIDataEx", $asm.$);

    Bridge.apply($asm.$.UIDataEx, {
        f1: function (n) {
            return n.Data;
        }
    });

    Bridge.define("JSLib.Controller.ControllerBase", {
        inherits: [JSLib.Mobile.UIBase],
        Content: null,
        HtmlContent: null,
        config: {
            events: {
                OnLoad: null,
                OnShow: null
            },
            properties: {
                PageContainer: null
            }
        },
        ctor: function () {
            this.$initialize();
            JSLib.Mobile.UIBase.ctor.call(this);
            this.addOnLoad($asm.$.JSLib.Controller.ControllerBase.f1);
        },
        BeforeLoad: function () {
            return null;
        },
        BuildController: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                task, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3], $step);
                            switch ($step) {
                                case 0: {
                                    task = this.BeforeLoad();
                                        if (task != null) {
                                            $step = 1;
                                            continue;
                                        } 
                                        $step = 3;
                                        continue;
                                }
                                case 1: {
                                    $task1 = task;
                                        $step = 2;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 2: {
                                    $task1.getAwaitedResult();
                                    $step = 3;
                                    continue;
                                }
                                case 3: {
                                    this.HtmlContent = this.GetHtmlContent();
                                        this.Content = $(this.HtmlContent);
                                        this.AfterBuildController();
                                    $tcs.setResult(null);
                                    return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        AfterBuildController: function () {

        },
        FindMemberAndBindEvent: function () {
            this.pageObject = this.Content;
            this.InitialComponent();
            !Bridge.staticEquals(this.OnLoad, null) ? this.OnLoad() : null;
        },
        Show: function () {
            this.pageObject.show();
            !Bridge.staticEquals(this.OnShow, null) ? this.OnShow() : null;
        },
        DataBind: function (data) {
            return JSLib.Data.DataBindHelper.Bind(data, Bridge.Reflection.getTypeFullName(Bridge.getType(this)));
        },
        Destroy: function () {
            JSLib.Mobile.UIBase.prototype.Destroy.call(this);

            JSLib.Data.DataBindHelper.RemoveBindData(this.UniqueId);
            this.DestoryIscroll();

            this.DestoryComponent();
            if (this.Content != null) {
                this.Content.unbind().off().remove();
                this.Content = null;
            }
            if (this.pageObject != null) {
                this.pageObject.unbind().off().remove();
                this.pageObject = null;
            }

        }
    });

    Bridge.ns("JSLib.Controller.ControllerBase", $asm.$);

    Bridge.apply($asm.$.JSLib.Controller.ControllerBase, {
        f1: function () {
        }
    });

    Bridge.define("JSLib.Data.DirectionDictionary$1", function (TValue) { return {
        inherits: [JSLib.Widget.ViewPager.FixedLengthDictionary$2(System.Int32,TValue)],
        ctor: function (maxCount) {
            if (maxCount === void 0) { maxCount = 5; }

            this.$initialize();
            JSLib.Widget.ViewPager.FixedLengthDictionary$2(System.Int32,TValue).ctor.call(this, maxCount);

        },
        AddData: function (value) {
            //this.AddItem
        }
    }; });

    Bridge.define("JSLib.Mobile.AppGlobalTemplate", {
        inherits: [JSLib.Controller.RazorTemplate],
        GetErrorPage: function (errorInfo) {
            return new System.Web.WebPages.HelperResult(Bridge.fn.bind(this, function (__razor_helper_writer) {




                this.WriteLiteralTo(__razor_helper_writer, "    <div data-role='page' class='ErrorPage'>\r\n        <p class=\"ErrorTitle\"> 软件出现异常：</p>\r\n        <p class=\"ErrorMessage\">");


                this.WriteTo(__razor_helper_writer, errorInfo);

                this.WriteLiteralTo(__razor_helper_writer, "</p>\r\n        <a class=\"ErrorBackButton\" data-appback=''>返回</a>\r\n    </div>\r\n");



            }));

        },
        Execute: function () {


            this.WriteLiteral("\r\n");



            this.WriteLiteral("\r\n ");


        }
    });

    Bridge.define("JSLib.Mobile.BasePage", {
        inherits: [JSLib.Mobile.UIBase,JSLib.Mobile.IShowLoading],
        statics: {
            ctor: function () {
            },
            LogError: function (ex) {
                var innerException = null;
                innerException = ex;
                while (innerException.getInnerException() != null) {
                    innerException = innerException.getInnerException();
                }
                var args = Bridge.merge(new JSLib.Mobile.ApplicationErrorArgs(), {
                    ErrorMessage: innerException.getMessage(),
                    Stack: innerException.getStackTrace()
                } );
                JSLib.Mobile.Application.RaiseError(args);
            }
        },
        IsPrepareDataError: false,
        IsIgnoreInHistory: false,
        InitialData: null,
        isDestroyed: false,
        config: {
            events: {
                OnPageInit: null,
                OnPageBeforeShow: null,
                OnPageShow: null,
                OnPageHide: null,
                OnDestroy: null
            },
            properties: {
                pageTranslateAnimation: 0
            },
            alias: [
            "ShowLoading", "JSLib$Mobile$IShowLoading$ShowLoading"
            ],
            init: function () {
                this.LastShowDateTime = new Date(-864e13);
            }
        },
        ctor: function () {
            this.$initialize();
            JSLib.Mobile.UIBase.ctor.call(this);
            this.LastShowDateTime = new Date();
        },
        getInitialDataObject: function () {
            return this.InitialData;
        },
        setInitialDataObject: function (value) {
            this.InitialData = value;
        },
        getdelayTime: function () {
            return JSLib.Mobile.Application.DeviceType === JSLib.Mobile.DeviceType.Android ? 400 : 0;
        },
        getDisableSwipBack: function () {
            return false;
        },
        getPageContainer: function () {
            if (this.pageObject == null || this.pageObject.length === 0) {
                return null;
            }
            return JSLib.Controller.Panel.FromElement(this.pageObject[0]);
        },
        GetTraslationInOutClass: function () {
            var baseInClass = "slideIn";
            var baseOutClass = "slideInReverse";
            if (this.getpageTranslateAnimation() === JSLib.Mobile.PageTranslateAnimation.No) {
                return { item1: System.String.concat("no_", baseInClass), item2: System.String.concat("no_", baseOutClass) };
            } else if (this.getpageTranslateAnimation() === JSLib.Mobile.PageTranslateAnimation.Default) {
                return { item1: baseInClass, item2: baseOutClass };
            }
            return null;
        },
        ClearOldUIData: function () {

        },
        Hide: function () {
            this.pageObject != null ? this.pageObject.hide() : null;
            !Bridge.staticEquals(this.OnPageHide, null) ? this.OnPageHide() : null;
            return this.pageObject;
        },
        Show: function (animate) {
            var $step = 0,
                $task1, 
                $taskResult1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                isFirstPage, 
                $t, 
                pageInClass, 
                tsk, 
                onAnimationEnd, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3,4,6], $step);
                            switch ($step) {
                                case 0: {
                                    if (animate === void 0) { animate = true; }
                                        isFirstPage = JSLib.Mobile.MobilePage.DomPageRepository.getCount() === 1;
                                        if (!JSLib.JSLibConfig.PageTransitionEffect || isFirstPage) {
                                            animate = false;
                                        }
                                        this.LastShowDateTime = new Date();
                                        !Bridge.staticEquals(this.OnPageBeforeShow, null) ? this.OnPageBeforeShow() : null;
                                        if (this.pageObject != null) {
                                            $step = 1;
                                            continue;
                                        } 
                                        $step = 6;
                                        continue;
                                }
                                case 1: {
                                    this.pageObject.css("zIndex", (($t = (JSLib.Mobile.MobilePage.CurrentPageZIndex + 1) | 0, JSLib.Mobile.MobilePage.CurrentPageZIndex = $t, $t)));

                                        //前进使用的动画
                                        if (animate) {
                                            $step = 2;
                                            continue;
                                        } else  {
                                            $step = 4;
                                            continue;
                                        }
                                }
                                case 2: {
                                    pageInClass = this.GetTraslationInOutClass().item1;
                                        tsk = new System.Threading.Tasks.TaskCompletionSource();
                                        onAnimationEnd = null;
                                        onAnimationEnd = Bridge.fn.bind(this, function () {
                                            this.pageObject.off("webkitAnimationEnd", onAnimationEnd);
                                            this.pageObject.removeClass(pageInClass);
                                            tsk.setResult(null);
                                        });
                                        this.pageObject.on("webkitAnimationEnd", onAnimationEnd);
                                        this.pageObject.addClass(pageInClass).show();
                                        $task1 = tsk.task;
                                        $step = 3;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 3: {
                                    $taskResult1 = $task1.getAwaitedResult();
                                    $step = 5;
                                    continue;
                                }
                                case 4: {
                                    this.pageObject.show();
                                    $step = 5;
                                    continue;
                                }

                                case 6: {
                                    
                                        if (!Bridge.staticEquals(this.OnPageShow, null)) {
                                            window.setTimeout(Bridge.fn.bind(this, function () {
                                                try {
                                                    this.OnPageShow();
                                                }
                                                catch (ex) {
                                                    ex = System.Exception.create(ex);
                                                    JSLib.Mobile.BasePage.LogError(ex);
                                                }
                                            }), this.getdelayTime());
                                        }

                                        //页面显示100ms后，重新计算滚动区域
                                        window.setTimeout(Bridge.fn.bind(this, $asm.$.JSLib.Mobile.BasePage.f1), 100);
                                    $tcs.setResult(null);
                                    return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        DataBind: function (data) {
            return JSLib.Data.DataBindHelper.Bind(data, Bridge.Reflection.getTypeFullName(Bridge.getType(this)));
        },
        Destroy: function () {
            JSLib.Mobile.UIBase.prototype.Destroy.call(this);

            JSLib.Data.DataBindHelper.RemoveBindData(this.UniqueId);

            JSLib.Mobile.Application.SystemLog$1("销毁页面:", Bridge.Reflection.getTypeFullName(Bridge.getType(this)));
            try {
                if (!Bridge.staticEquals(this.OnDestroy, null)) {
                    this.OnDestroy(this, null);
                }
            }
            catch (ex) {
                ex = System.Exception.create(ex);
                console.error(ex);
            }

            this.DestroyImpl(true);
        },
        DestroyImpl: function (Deep) {
            if (Deep === void 0) { Deep = true; }
            if (this.isDestroyed) {
                return;
            }
            this.isDestroyed = true;

            this.DestoryComponent();

            this.DestoryIscroll();


            var currentPageType = Bridge.getType(this);
            var removePage = System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).firstOrDefault(Bridge.fn.bind(this, $asm.$.JSLib.Mobile.BasePage.f2), null);
            JSLib.Mobile.MobilePage.DomPageRepository.remove(removePage);

            //检查该类型在Dom树中没有存在的实例对像，则移除该类型的样式表链接
            var isExistCurrentTypeInstance = System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).any(function (n) {
                    return Bridge.referenceEquals(n.PageData.PageType, removePage.PageData.PageType);
                });

            this.pageObject.unbind().off();
            this.pageObject.remove();

            if (Deep) {
                if (JSLib.Mobile.Application.AutoLoadCss && !JSLib.Mobile.Application.PreserveCss) {
                    if (!isExistCurrentTypeInstance) {
                        $(System.String.format("link[data-type={0}]", JSLib.Mobile.MobilePage.GeneratePageId$1(currentPageType))).remove();
                    }
                }
            }
            if (Deep) {
                this.pageObject = null;
                this.InitialData = null;
                this.OnPageInit = null;
                this.OnPageShow = null;
                this.OnPageHide = null;
                this.OnPageBeforeShow = null;
                this.LastShowDateTime=null;
            }
        },
        TriggerInitEvent: function () {
            JSLib.Mobile.Application.SystemLog$1("触发页面Init事件:", Bridge.Reflection.getTypeFullName(Bridge.getType(this)));
            this.pageObject.on("click", "[data-role=BackButton]", $asm.$.JSLib.Mobile.BasePage.f3);
            //向右滑的手势执行后退
            if (JSLib.Mobile.Application.EnableSwipeLeftToRightToBack && !this.getDisableSwipBack()) {
                this.pageObject.on("swipeRight", $asm.$.JSLib.Mobile.BasePage.f3);
            }

            if (JSLib.Mobile.Application.EnableSwipeRightToLeftFoward && !this.getDisableSwipBack()) {
                this.pageObject.on("swipeLeft", $asm.$.JSLib.Mobile.BasePage.f4);
            }


            if (!Bridge.staticEquals(this.OnPageInit, null)) {

                //Android机器等候400毫秒才绑定页面事件，阻止事件穿透的影响
                window.setTimeout(Bridge.fn.bind(this, function () {
                    try {
                        this.OnPageInit();
                    }
                    catch (ex) {
                        ex = System.Exception.create(ex);
                        console.error(ex);
                        JSLib.Mobile.BasePage.LogError(ex);
                    }
                }), this.getdelayTime());

            }


        },
        TriggerPageShowEvent: function () {
            if (!Bridge.staticEquals(this.OnPageBeforeShow, null)) {
                try {
                    this.OnPageBeforeShow();
                }
                catch (ex) {
                    ex = System.Exception.create(ex);
                    JSLib.Mobile.BasePage.LogError(ex);
                }
            }
            if (!Bridge.staticEquals(this.OnPageShow, null)) {
                //Android机器等候400毫秒才绑定页面事件，阻止事件穿透的影响
                window.setTimeout(Bridge.fn.bind(this, function () {
                    try {
                        this.OnPageShow();
                    }
                    catch (ex1) {
                        ex1 = System.Exception.create(ex1);
                        JSLib.Mobile.BasePage.LogError(ex1);
                    }
                }), this.getdelayTime());

            }
        },
        TriggerHideEvent: function () {
            this.pageObject.hide();
            if (!Bridge.staticEquals(this.OnPageHide, null)) {
                try {
                    this.OnPageHide();
                }
                catch (ex) {
                    ex = System.Exception.create(ex);
                    JSLib.Mobile.BasePage.LogError(ex);
                }
            }
        },
        ReloadPage: function () {
            var $step = 0,
                $task1, 
                $taskResult1, 
                $task2, 
                $jumpFromFinally, 
                $returnValue, 
                pageType, 
                isExistPage, 
                ex, 
                $async_e, 
                $async_e1, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1,3,4,5,6,7,8], $step);
                            switch ($step) {
                                case 0: {
                                    this.DestroyImpl(false);
                                        $task1 = this.PreparePage();
                                        $step = 1;
                                        $task1.continueWith($asyncBody, true);
                                        return;
                                }
                                case 1: {
                                    $taskResult1 = $task1.getAwaitedResult();
                                    this.pageObject = $taskResult1;

                                        JSLib.Mobile.MobilePage.PageContainer.append(this.pageObject);
                                        this.InitialComponent();
                                        pageType = Bridge.getType(this);
                                        this.pageObject.attr("data-sid", JSLib.Mobile.MobilePage.GeneratePageId$1(pageType, this.InitialData));
                                        //如果加载的页面中不包含即将跳转的页面，则创建对应的页面，并将其加载到dom树中
                                        isExistPage = System.Linq.Enumerable.from(JSLib.Mobile.MobilePage.DomPageRepository).any(Bridge.fn.bind(this, function (n) {
                                                return n.PageData.GetHashCode() === new JSLib.Mobile.PageData(pageType, this.InitialData).GetHashCode();
                                            }));
                                        if (!isExistPage) {
                                            JSLib.Mobile.MobilePage.DomPageRepository.add(Bridge.merge(new JSLib.Mobile.PageInstanceData(), {
                                                PageData: new JSLib.Mobile.PageData(pageType, this.InitialData),
                                                BasePage: this
                                            } ));
                                        }

                                        if (!this.IsPrepareDataError) {
                                            $step = 2;
                                            continue;
                                        } else  {
                                            $step = 7;
                                            continue;
                                        }
                                }

                                case 3: {
                                    this.TriggerInitEvent();
                                        $task2 = this.Show();
                                        $step = 4;
                                        $task2.continueWith($asyncBody, true);
                                        return;
                                }
                                case 4: {
                                    $task2.getAwaitedResult();
                                    if (!Bridge.staticEquals(this.OnPageShow, null)) {
                                            window.setTimeout(Bridge.fn.bind(this, function () {
                                                try {
                                                    this.OnPageShow();
                                                }
                                                catch (ex) {
                                                    ex = System.Exception.create(ex);
                                                    JSLib.Mobile.BasePage.LogError(ex);
                                                }
                                            }), this.getdelayTime());
                                        }
                                    $step = 6;
                                    continue;
                                }
                                case 5: {
                                    console.error(ex);
                                        JSLib.Mobile.BasePage.LogError(ex);
                                        $async_e = null;
                                    $step = 6;
                                    continue;
                                }
                                case 6: {
                                    $step = 8;
                                    continue;
                                }
                                case 7: {
                                    this.pageObject.show();
                                    $step = 8;
                                    continue;
                                }
                                case 8: {
                                    
                                        this.isDestroyed = false;
                                    return;
                                }
                                default: {
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        if ( $step >= 3 && $step <= 4 ){
                            ex = $async_e;
                            $step = 5;
                            $asyncBody();
                            return;
                        }
                        throw $async_e;
                    }
                }, arguments);

            $asyncBody();
        },
        ShowLoading: function (maxShowTime) {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                loadingDialog, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1], $step);
                            switch ($step) {
                                case 0: {
                                    if (maxShowTime === void 0) { maxShowTime = 0; }
                                        loadingDialog = new JSLib.Widget.Common.LoadingDialog();
                                        if (this.getPageContainer() == null) {
                                            $tcs.setResult(loadingDialog);
                                            return;
                                        }
                                        $task1 = this.getPageContainer().AddChild(loadingDialog, true);
                                        $step = 1;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 1: {
                                    $task1.getAwaitedResult();
                                    if (maxShowTime > 0) {
                                            window.setTimeout(function () {
                                                loadingDialog.Destroy();
                                            }, ((maxShowTime * 1000) | 0));
                                        }
                                        $tcs.setResult(loadingDialog);
                                        return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        }
    });

    Bridge.ns("JSLib.Mobile.BasePage", $asm.$);

    Bridge.apply($asm.$.JSLib.Mobile.BasePage, {
        f1: function () {
            this.RefreshPageScroll();
        },
        f2: function (n) {
            return Bridge.referenceEquals(n.BasePage, this);
        },
        f3: function (event) {
            JSLib.Mobile.Application.Back();
        },
        f4: function (event) {
            JSLib.Mobile.Application.Foward();
        }
    });

    Bridge.define("JSLib.Widget.Panel.ModalPanelTemplate", {
        inherits: [JSLib.Controller.RazorTemplate],
        GetModalPanelTemplate: function (content, showOKButton, showCancelButton, title, ContainerClass, userContainerWidth) {
            if (ContainerClass === void 0) { ContainerClass = ""; }
            if (userContainerWidth === void 0) { userContainerWidth = null; }
            return new System.Web.WebPages.HelperResult(Bridge.fn.bind(this, function (__razor_helper_writer) {




                this.WriteLiteralTo(__razor_helper_writer, "    <div data-type=\"");


                this.WriteTo(__razor_helper_writer, Bridge.Reflection.getTypeFullName(Bridge.getType(this)));

                this.WriteLiteralTo(__razor_helper_writer, "\" class='c-modal-window ");


                this.WriteTo(__razor_helper_writer, ContainerClass);

                this.WriteLiteralTo(__razor_helper_writer, "' >\r\n        <div class='c-modal-content'>\r\n            \r\n");



                var userContainerCss = "";
                if (userContainerWidth != null) {
                    userContainerCss = System.String.concat(userContainerCss, (System.String.format("width:{0}px", userContainerWidth)));
                }


                this.WriteLiteralTo(__razor_helper_writer, "            <div class=\"c-modal-usercontent\" style=\"");


                this.WriteTo(__razor_helper_writer, userContainerCss);

                this.WriteLiteralTo(__razor_helper_writer, "\">\r\n\r\n");


                if (!System.String.isNullOrEmpty(title)) {

                    this.WriteLiteralTo(__razor_helper_writer, "                    <div class=\"c-modal-title\">\r\n                        ");


                    this.WriteTo(__razor_helper_writer, title);

                    this.WriteLiteralTo(__razor_helper_writer, "\r\n                    </div>\r\n");


                }

                this.WriteLiteralTo(__razor_helper_writer, "\r\n                ");


                this.WriteTo(__razor_helper_writer, content);

                this.WriteLiteralTo(__razor_helper_writer, "\r\n");


                if (showOKButton || showCancelButton) {

                    this.WriteLiteralTo(__razor_helper_writer, "                    <div class='c-modal-toolbar'>\r\n");


                    if (showOKButton) {

                        this.WriteLiteralTo(__razor_helper_writer, "                            <input type='button' value='确认' id='btnOK' class='c-btn c-modal-button'/>\r\n");


                    }

                    this.WriteLiteralTo(__razor_helper_writer, "\r\n");


                    if (showCancelButton) {

                        this.WriteLiteralTo(__razor_helper_writer, "                            <input type='button' value='取消' id='btnCancel' class='c-btn c-modal-button'/>\r\n");


                    }

                    this.WriteLiteralTo(__razor_helper_writer, "                    </div>\r\n");


                }

                this.WriteLiteralTo(__razor_helper_writer, "            </div>\r\n\r\n        </div>\r\n\r\n    </div>\r\n");



            }));

        },
        Execute: function () {


            this.WriteLiteral("\r\n");




        }
    });

    Bridge.define("JSLib.Widget.ViewPager.ViewPageItem$1", function (T) { return {
        inherits: [JSLib.Widget.ViewPager.IViewPagerItem],
        pageDom: null,
        PageIndex: 0,
        PageData: Bridge.getDefaultValue(T),
        config: {
            alias: [
            "GetController", "JSLib$Widget$ViewPager$IViewPagerItem$GetController",
            "Dispose", "JSLib$Widget$ViewPager$IViewPagerItem$Dispose"
            ]
        },
        $ctor1: function (pageIndex, getPageDom) {
            this.$initialize();
            this.pageDom = getPageDom(pageIndex);
        },
        ctor: function (data, getPageDomByData) {
            this.$initialize();
            this.PageData = data;
            this.pageDom = getPageDomByData(data);
        },
        GetController: function () {
            return this.pageDom;
        },
        Dispose: function () {
            this.pageDom.unbind();
            this.pageDom.remove();
            this.pageDom = null;
        }
    }; });

    Bridge.define("JSLib.Controller.UIController", {
        inherits: [JSLib.Controller.ControllerBase],
        config: {
            properties: {
                Width: null,
                Height: null
            }
        }
    });

    Bridge.define("JSLib.Widget.Common.CommonDialog", {
        inherits: [JSLib.Controller.ControllerBase,JSLib.Widget.IBackEvent],
        statics: {
            Confirm: function (title, message) {
                var $step = 0,
                    $task1, 
                    $task2, 
                    $taskResult2, 
                    $jumpFromFinally, 
                    $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                    $returnValue, 
                    dialog, 
                    container, 
                    result, 
                    $async_e, 
                    $asyncBody = Bridge.fn.bind(this, function () {
                        try {
                            for (;;) {
                                $step = System.Array.min([0,1,2], $step);
                                switch ($step) {
                                    case 0: {
                                        dialog = Bridge.merge(new JSLib.Widget.Common.CommonDialog(), {
                                                Title: title,
                                                Message: message
                                            } );

                                            container = JSLib.Controller.Panel.FromElement(document.body);
                                            $task1 = container.AddChild(dialog, true);
                                            $step = 1;
                                            $task1.continueWith($asyncBody);
                                            return;
                                    }
                                    case 1: {
                                        $task1.getAwaitedResult();
                                        result = new System.Threading.Tasks.TaskCompletionSource();
                                            dialog.addOnOKClicked(function () {
                                                result.setResult(true);
                                                dialog.Destroy();
                                            });
                                            dialog.addOnCanceled(function () {
                                                result.setResult(false);
                                                dialog.Destroy();
                                            });
                                            $task2 = result.task;
                                            $step = 2;
                                            $task2.continueWith($asyncBody);
                                            return;
                                    }
                                    case 2: {
                                        $taskResult2 = $task2.getAwaitedResult();
                                        $tcs.setResult($taskResult2);
                                            return;
                                    }
                                    default: {
                                        $tcs.setResult(null);
                                        return;
                                    }
                                }
                            }
                        } catch($async_e1) {
                            $async_e = System.Exception.create($async_e1);
                            $tcs.setException($async_e);
                        }
                    }, arguments);

                $asyncBody();
                return $tcs.task;
            }
        },
        Title: null,
        Message: null,
        btnOK: null,
        btnCancel: null,
        config: {
            events: {
                OnOKClicked: null,
                OnCanceled: null
            },
            alias: [
            "OnBackButton", "JSLib$Widget$IBackEvent$OnBackButton"
            ]
        },
        ctor: function () {
            this.$initialize();
            JSLib.Controller.ControllerBase.ctor.call(this);
            this.addOnLoad(Bridge.fn.bind(this, this.CommonDialog_OnLoad));
            JSLib.Mobile.NavigationManager.RegisterBackControl(this);
        },
        CommonDialog_OnLoad: function () {
            this.btnOK.click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.CommonDialog.f1));
            this.btnCancel.click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.CommonDialog.f2));

        },
        OnBackButton: function (args) {
            //按下后退铵键时，关闭此窗体
            this.btnCancel.click();
            //关闭此窗口后，不再继续执行后退操作
            args.IsContinueGoBack = false;
            this.Destroy();
        },
        Destroy: function () {
            this.OnOKClicked = null;
            JSLib.Mobile.NavigationManager.UnRegisterBackControl(this);
            JSLib.Controller.ControllerBase.prototype.Destroy.call(this);
        },
        Execute: function () {

            this.WriteLiteral("<div class=\"c-commonDialog\">\r\n    <div class=\"c-dialog-usercontent\">\r\n        <div class=\"c-dialog-title\">\r\n            ");


            this.Write(this.Title);

            this.WriteLiteral("\r\n        </div>\r\n        <div class=\"c-dialog-message\">\r\n            ");


            this.Write(this.Message);

            this.WriteLiteral("\n        </div>\n        <div class=\"c-dialog-toolbar\">\n            <div class=\"c-dialog-toolbar-button\" id=\"btnOK\">\n                确认\n            </div>\n            <div class=\"c-dialog-toolbar-button\" id=\"btnCancel\">\n                取消\n            </div>\n        </div>\n    </div>\n\n</div>\n");


        },
        InitialComponent: function () {
            this.btnOK = this.pageObject.find("#btnOK");
            this.btnCancel = this.pageObject.find("#btnCancel");
        },
        DestoryComponent: function () {
            if (this.btnOK != null) {
                this.btnOK.unbind().off();
                this.btnOK = null;
            }
            if (this.btnCancel != null) {
                this.btnCancel.unbind().off();
                this.btnCancel = null;
            }
        }
    });

    Bridge.ns("JSLib.Widget.Common.CommonDialog", $asm.$);

    Bridge.apply($asm.$.JSLib.Widget.Common.CommonDialog, {
        f1: function (event) {
            !Bridge.staticEquals(this.OnOKClicked, null) ? this.OnOKClicked(null, null) : null;
        },
        f2: function (event) {
            if (!Bridge.staticEquals(this.OnCanceled, null)) {
                this.OnCanceled(null, null);
            } else {
                this.Destroy();
            }
        }
    });

    Bridge.define("JSLib.Widget.Common.LoadingDialog", {
        inherits: [JSLib.Controller.ControllerBase],
        statics: {
            CurrentZIndex: 1000000
        },
        ctor: function () {
            this.$initialize();
            JSLib.Controller.ControllerBase.ctor.call(this);
            this.addOnLoad(Bridge.fn.bind(this, this.LoadingDialog_OnLoad));
        },
        LoadingDialog_OnLoad: function () {
            if (this.pageObject.parent().length > 0) {
                var position = window.getComputedStyle(this.pageObject.parent()[0]).position;
                if (position !== "relative" && position !== "absolute") {
                    this.pageObject.parent()[0].style.position = "relative";
                }
            }
        },
        CloseLoading: function () {
            this.Destroy();
        },
        Execute: function () {
            var $t;

            this.WriteLiteral("<div class=\"c-n-loaingPanel\" style=\"z-index:");


            this.Write(Bridge.identity(JSLib.Widget.Common.LoadingDialog.CurrentZIndex, ($t = (JSLib.Widget.Common.LoadingDialog.CurrentZIndex + 1) | 0, JSLib.Widget.Common.LoadingDialog.CurrentZIndex = $t, $t)));

            this.WriteLiteral("\">\n    <img src=\"res/img/ajax-loader.gif\" class=\"c-loadingGIF\">\n</div>");


        },
        InitialComponent: function () {
        }
    });

    Bridge.define("JSLib.Widget.ViewPager.ViewPageItem", {
        inherits: [JSLib.Widget.ViewPager.ViewPageItem$1(Object)],
        ctor: function (pageIndex, getPageDom) {
            this.$initialize();
            JSLib.Widget.ViewPager.ViewPageItem$1(Object).$ctor1.call(this, pageIndex, getPageDom);
        },
        $ctor1: function (data, getPageDomByData) {
            this.$initialize();
            JSLib.Widget.ViewPager.ViewPageItem$1(Object).ctor.call(this, data, getPageDomByData);
        }
    });

    Bridge.define("Phone.RazorMobilePage", {
        inherits: [JSLib.Mobile.BasePage],
        LastPageData: null,
        config: {
            properties: {
                PrepareErrroInfo: null,
                IsDataChanged: false
            }
        },
        ctor: function () {
            this.$initialize();
            JSLib.Mobile.BasePage.ctor.call(this);
            JSLib.Mobile.MobilePage.showLoadingMessage = false;
            this.addOnPageBeforeShow(Bridge.fn.bind(this, $asm.$.Phone.RazorMobilePage.f1));

        },
        PreparePage: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                content, 
                prepareTask, 
                ex, 
                $async_e, 
                errorInfo, 
                $async_e1, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3,4,5,6], $step);
                            switch ($step) {
                                case 0: {
                                    content = "";
                                    $step = 1;
                                    continue;
                                }
                                case 1: {
                                    prepareTask = this.PrepareData();
                                        if (prepareTask != null) {
                                            $step = 2;
                                            continue;
                                        } 
                                        $step = 4;
                                        continue;
                                }
                                case 2: {
                                    $task1 = prepareTask;
                                        $step = 3;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 3: {
                                    $task1.getAwaitedResult();
                                    $step = 4;
                                    continue;
                                }
                                case 4: {
                                    this.Execute();
                                        content = this.contentBuilder.toString();
                                    $step = 6;
                                    continue;
                                }
                                case 5: {
                                    this.IsPrepareDataError = true;
                                        console.error(ex);
                                        content = new JSLib.Mobile.AppGlobalTemplate().GetErrorPage(this.getPrepareErrroInfo()).toString();
                                        $async_e = null;
                                    $step = 6;
                                    continue;
                                }
                                case 6: {
                                    
                                        //清除构建器内容，防止内容重复
                                        this.contentBuilder.clear();
                                        this.pageObject = $(content);
                                        if (this.pageObject.length !== 1) {
                                            errorInfo = System.String.concat(Bridge.Reflection.getTypeFullName(Bridge.getType(this)), "页面包含多个顶级对像!");
                                            console.error(errorInfo);
                                            throw new System.ArgumentException(errorInfo);
                                        }
                                        this.pageObject.on("click", "a[data-appback]", $asm.$.Phone.RazorMobilePage.f2);
                                        $tcs.setResult(this.pageObject);
                                        return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        if ( $step >= 1 && $step <= 4 ){
                            ex = $async_e;
                            $step = 5;
                            $asyncBody();
                            return;
                        }
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        PrepareData: function () {
            return null;
        }
    });

    Bridge.ns("Phone.RazorMobilePage", $asm.$);

    Bridge.apply($asm.$.Phone.RazorMobilePage, {
        f1: function () {
            this.setIsDataChanged(!Bridge.referenceEquals(this.LastPageData, this.InitialData));
            this.LastPageData = this.InitialData;
        },
        f2: function (event) {
            JSLib.Mobile.Application.Back();
        }
    });

    Bridge.define("JSLib.Controller.Panel", {
        inherits: [JSLib.Controller.UIController],
        statics: {
            FromElement: function (divElement) {
                return new JSLib.Controller.Panel(divElement);
            }
        },
        Child: null,
        config: {
            init: function () {
                this.Child = new (System.Collections.Generic.List$1(JSLib.Controller.ControllerBase))();
            }
        },
        ctor: function (content) {
            this.$initialize();
            JSLib.Controller.UIController.ctor.call(this);
            this.Content = $(content);
        },
        Destroy: function () {
            this.RemoveChild();
            JSLib.Controller.UIController.prototype.Destroy.call(this);

        },
        AddChild: function (controller, isPrePend, isHidden, page) {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1], $step);
                            switch ($step) {
                                case 0: {
                                    if (isPrePend === void 0) { isPrePend = false; }
                                        if (isHidden === void 0) { isHidden = false; }
                                        if (page === void 0) { page = null; }
                                        controller.setPageContainer(page);
                                        this.Child.add(controller);
                                        $task1 = controller.BuildController();
                                        $step = 1;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 1: {
                                    $task1.getAwaitedResult();
                                    if (isPrePend) {
                                            this.Content.prepend(controller.Content);
                                        } else {
                                            this.Content.append(controller.Content);
                                        }
                                        controller.FindMemberAndBindEvent();
                                        if (isHidden) {
                                            controller.Content.hide();
                                        }
                                    $tcs.setResult(null);
                                    return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        RemoveChild$1: function (index) {
            var item = this.Child.getItem(index);
            item.Destroy();
            this.Child.removeAt(index);
        },
        RemoveChild: function () {
            var $t;
            $t = Bridge.getEnumerator(this.Child);
            while ($t.moveNext()) {
                var item = $t.getCurrent();
                try {
                    item.Destroy();
                }
                catch ($e1) {
                    $e1 = System.Exception.create($e1);
                }
            }
        },
        GetChild: function (index) {
            return this.Child.getItem(index);
        }
    });

    Bridge.define("JSLib.Widget.Panel.ModalPanel", {
        inherits: [JSLib.Controller.UIController],
        statics: {
            CurrentPageIndex: 10000,
            modalPanles: null,
            config: {
                init: function () {
                    this.modalPanles = new (System.Collections.Generic.List$1(JSLib.Widget.Panel.ModalPanel))();
                }
            }
        },
        CloseOnModalBackClick: true,
        ShowOKButton: false,
        ShowCancelButton: false,
        Title: null,
        config: {
            events: {
                OnOKButtonClick: null,
                OnModalWindowClick: null
            },
            properties: {
                ContainerClass: null,
                UserContainerWidth: null
            }
        },
        ctor: function () {
            this.$initialize();
            JSLib.Controller.UIController.ctor.call(this);
            this.addOnLoad(Bridge.fn.bind(this, this.ModalPanel_OnLoad));
        },
        AfterBuildController: function () {
            this.HtmlContent = new JSLib.Widget.Panel.ModalPanelTemplate().GetModalPanelTemplate(this.HtmlContent, this.ShowOKButton, this.ShowCancelButton, this.Title, this.getContainerClass(), this.getUserContainerWidth()).toString();
            this.Content = $(this.HtmlContent);
        },
        ModalPanel_OnLoad: function () {
            if (window.IsDebugMode) {
                this.pageObject.attr("data-type", Bridge.Reflection.getTypeName(Bridge.getType(this)));
            }

            this.Content.click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Panel.ModalPanel.f1));

            if (this.ShowCancelButton) {
                this.Content.find("#btnCancel").click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Panel.ModalPanel.f2));
            }

            if (this.ShowOKButton) {
                this.Content.find("#btnOK").click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Panel.ModalPanel.f3));
            }

            JSLib.Widget.Panel.ModalPanel.modalPanles.add(this);
        },
        Destroy: function () {
            JSLib.Widget.Panel.ModalPanel.modalPanles.remove(this);
            JSLib.Controller.UIController.prototype.Destroy.call(this);
        },
        ShowAsGlobalModalPanel: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                $t, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1], $step);
                            switch ($step) {
                                case 0: {
                                    $task1 = JSLib.Controller.Panel.FromElement($("body")[0]).AddChild(this);
                                        $step = 1;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 1: {
                                    $task1.getAwaitedResult();
                                    this.Content.css("z-index", Bridge.identity(JSLib.Widget.Panel.ModalPanel.CurrentPageIndex, ($t = (JSLib.Widget.Panel.ModalPanel.CurrentPageIndex + 1) | 0, JSLib.Widget.Panel.ModalPanel.CurrentPageIndex = $t, $t)));
                                        $tcs.setResult(this);
                                        return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        ShowModalPanelTo: function (page) {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                $t, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1], $step);
                            switch ($step) {
                                case 0: {
                                    $task1 = JSLib.Controller.Panel.FromElement(page.pageObject[0]).AddChild(this, true, false, page);
                                        $step = 1;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 1: {
                                    $task1.getAwaitedResult();
                                    this.Content.css("z-index", Bridge.identity(JSLib.Widget.Panel.ModalPanel.CurrentPageIndex, ($t = (JSLib.Widget.Panel.ModalPanel.CurrentPageIndex + 1) | 0, JSLib.Widget.Panel.ModalPanel.CurrentPageIndex = $t, $t)));
                                        $tcs.setResult(this);
                                        return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        }
    });

    Bridge.ns("JSLib.Widget.Panel.ModalPanel", $asm.$);

    Bridge.apply($asm.$.JSLib.Widget.Panel.ModalPanel, {
        f1: function (event) {
            if (System.String.contains(event.target.className,"c-modal-window")) {
                if (!Bridge.staticEquals(this.OnModalWindowClick, null)) {
                    this.OnModalWindowClick();
                } else {
                    if (this.CloseOnModalBackClick) {
                        this.Destroy();
                    }
                }
            }
        },
        f2: function () {
            this.Destroy();
        },
        f3: function () {
            !Bridge.staticEquals(this.OnOKButtonClick, null) ? this.OnOKButtonClick() : null;
        }
    });

    Bridge.define("JSLib.Widget.ViewPager.ViewPager$1", function (T) { return {
        inherits: [JSLib.Controller.UIController],
        statics: {
            TranslateDuration: 500
        },
        ViewPageDic: null,
        getData: null,
        _havePrefetchData: null,
        ulList: null,
        deltaX: 0,
        deltaY: 0,
        containerWidth: 0,
        transX: 0,
        _maxPageCount: 0,
        padddingLeft: 0,
        CurPostion: 0,
        _snapThreshold: 0,
        config: {
            events: {
                OnPageChanged: null
            }
        },
        ctor: function (getData, haveprefetchData, snapThreshold, maxPageCount) {
            if (snapThreshold === void 0) { snapThreshold = 80; }
            if (maxPageCount === void 0) { maxPageCount = 3; }

            this.$initialize();
            JSLib.Controller.UIController.ctor.call(this);
            this._maxPageCount = maxPageCount;
            this.getData = getData;
            this._havePrefetchData = haveprefetchData || $asm.$.JSLib.Widget.ViewPager.ViewPager$1.f1;
            this._snapThreshold = snapThreshold;

            this.addOnLoad(Bridge.fn.bind(this, this.ViewPager_OnLoad));
        },
        getIsRightToLeft: function () {
            return this.deltaX < 0;
        },
        Reload: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    for (;;) {
                        $step = System.Array.min([0,1], $step);
                        switch ($step) {
                            case 0: {
                                this.ulList.empty();
                                    $task1 = this.InlitialData();
                                    $step = 1;
                                    $task1.continueWith($asyncBody, true);
                                    return;
                            }
                            case 1: {
                                $task1.getAwaitedResult();
                                return;
                            }
                            default: {
                                return;
                            }
                        }
                    }
                }, arguments);

            $asyncBody();
        },
        BuildController: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                task, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1,2,3], $step);
                            switch ($step) {
                                case 0: {
                                    task = this.BeforeLoad();
                                        if (task != null) {
                                            $step = 1;
                                            continue;
                                        } 
                                        $step = 3;
                                        continue;
                                }
                                case 1: {
                                    $task1 = task;
                                        $step = 2;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 2: {
                                    $task1.getAwaitedResult();
                                    $step = 3;
                                    continue;
                                }
                                case 3: {
                                    this.Content = $("<div></div>");
                                    $tcs.setResult(null);
                                    return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        ViewPager_OnLoad: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                startX, 
                startY, 
                currentX, 
                currentY, 
                endX, 
                isStart, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    for (;;) {
                        $step = System.Array.min([0,1], $step);
                        switch ($step) {
                            case 0: {
                                startX = 0;
                                    startY = 0;
                                    currentX = 0;
                                    currentY = 0;
                                    endX = 0;

                                    isStart = false;

                                    //滑动多长的距离后进行翻页
                                    this.transX = 0;

                                    this.containerWidth = window.innerWidth;
                                    this.Content.css("min-width", (((this.containerWidth * this._maxPageCount) | 0))+'px');

                                    this.Content.on("touchstart", Bridge.fn.bind(this, function (event) {
                                        isStart = true;
                                        this.Content[0].style.setwebkitTransitionDuration("0ms");
                                        startX = event.originalEvent.touches[0].pageX;
                                        startY = event.originalEvent.touches[0].pageY;
                                    }));
                                    this.Content.on("touchmove", Bridge.fn.bind(this, function (event) {
                                        if (!isStart) {
                                            return;
                                        }
                                        event.preventDefault();

                                        currentX = event.originalEvent.touches[0].pageX;
                                        currentY = event.originalEvent.touches[0].pageY;

                                        this.deltaX = (currentX - startX) | 0;
                                        this.deltaY = (currentY - startY) | 0;
                                        //如果主要是上下滑动，则取消左右的翻页效果
                                        if (Math.abs(this.deltaX) < Math.abs(this.deltaY)) {
                                            //isStart = false;
                                            return;
                                        }


                                        this.TranslateTo(((this.CurPostion + this.deltaX) | 0), 0);
                                    }));
                                    this.Content.on("touchend", Bridge.fn.bind(this, function (event) {
                                        if (!isStart) {
                                            return;
                                        }

                                        endX = event.originalEvent.changedTouches[0].pageX;
                                        this.deltaX = (endX - startX) | 0;

                                        //位移量不足，取消翻到下一页
                                        if (Math.abs(this.deltaX) < this._snapThreshold) {
                                            startX = 0;
                                            isStart = false;
                                            this.TranslateTo(this.CurPostion);
                                            return;
                                        }

                                        startX = 0;
                                        isStart = false;
                                        var gestureDirection = this.getIsRightToLeft() ? JSLib.Data.GestureDirection.RightToLeft : JSLib.Data.GestureDirection.LeftToRight;
                                        if (this.ViewPageDic.MoveStep(gestureDirection)) {
                                            this.UpdateElementClass();
                                        }
                                        //TranslateTo(CurPostion);
                                        window.setTimeout(Bridge.fn.bind(this, $asm.$.JSLib.Widget.ViewPager.ViewPager$1.f2), 100);
                                    }));

                                    $task1 = this.InlitialData();
                                    $step = 1;
                                    $task1.continueWith($asyncBody, true);
                                    return;
                            }
                            case 1: {
                                $task1.getAwaitedResult();
                                return;
                            }
                            default: {
                                return;
                            }
                        }
                    }
                }, arguments);

            $asyncBody();
        },
        InlitialData: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1], $step);
                            switch ($step) {
                                case 0: {
                                    this.ulList = $(System.String.format("<ul class='c-ViewPager' style='min-width:{0}px'></ul>", ((this.containerWidth * this._maxPageCount) | 0)));

                                        this.ViewPageDic = new (JSLib.Widget.ViewPager.FixedInfiniteQuee$1(T))(this.getData, this._havePrefetchData, this._maxPageCount);
                                        this.ViewPageDic.addOnCurPosChange(Bridge.fn.bind(this, $asm.$.JSLib.Widget.ViewPager.ViewPager$1.f3));

                                        this.ViewPageDic.addOnItemRemove(Bridge.fn.bind(this, $asm.$.JSLib.Widget.ViewPager.ViewPager$1.f4));
                                        this.ViewPageDic.addOnItemAdd(Bridge.fn.bind(this, $asm.$.JSLib.Widget.ViewPager.ViewPager$1.f5));
                                        this.ViewPageDic.addOnItemSet(Bridge.fn.bind(this, $asm.$.JSLib.Widget.ViewPager.ViewPager$1.f6));



                                        this.ViewPageDic.addOnCurrentDataChange(Bridge.fn.bind(this, function (sender, args) {

                                            this.UpdateElementClass();

                                            this.CurPostion = (((this.ViewPageDic.curPos * this.containerWidth) | 0) * -1) | 0;
                                            this.TranslateTo(this.CurPostion, 0);
                                            !Bridge.staticEquals(this.OnPageChanged, null) ? this.OnPageChanged(this, Bridge.merge(new (JSLib.Widget.ViewPager.PageChanged$1(T))(), {
                                                    Data: args.Data
                                                } )) : null;
                                            this.ScrollToTop();
                                        }));

                                        $task1 = this.ViewPageDic.InlitialData();
                                        $step = 1;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 1: {
                                    $task1.getAwaitedResult();
                                    
                                        this.ulList.appendTo(this.Content);
                                    $tcs.setResult(null);
                                    return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        },
        WarpDataItem: function (itemController) {
            var li = $("<li>");
            li.append(itemController);
            li.width(this.containerWidth);
            return li;
        },
        TranslateTo: function (x, duration) {
            if (duration === void 0) { duration = 500; }
            this.Content[0].style.setwebkitTransform("translate3d(" + x + "px,0,0)");
            this.Content[0].style.setwebkitTransitionDuration(duration + "ms");
        },
        UpdateElementClass: function () {
            var curItemClass = "c-vpi-cur";
            this.ulList.children("li").removeClass();
            var curItem = this.ulList.find(System.String.format("li:nth-child({0})", ((this.ViewPageDic.curPos + 1) | 0))).addClass(curItemClass);
            curItem.prev().addClass("c-vpi-pre");
            curItem.next().addClass("c-vpi-next");
        },
        GetCurrentPageIndex: function () {
            return this.ViewPageDic.curPos;
        },
        GetCurrentPageData: function () {
            return this.ViewPageDic.getItem(this.ViewPageDic.curPos);
        },
        MoveStep: function (direciton) {
            this.ViewPageDic.MoveStep(direciton);
        },
        ScrollToTop: function () {
            this.Content[0].style.overflow = "hidden";
            //this.ParentContainer[0].ScrollTop = 0;
            this.Content.scrollTop(0);
            this.Content[0].style.overflowX = "scroll";
        },
        Destroy: function () {
            var $t;
            if (this.ViewPageDic != null && this.ViewPageDic.data != null && this.ViewPageDic.data.getCount() > 0) {
                $t = Bridge.getEnumerator(this.ViewPageDic.data);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    item.JSLib$Widget$ViewPager$IViewPagerItem$Dispose();
                }
            }
            this.ViewPageDic = null;
            this.CurPostion = 0;

            this.Content.empty();
            this.Content.unbind();

            JSLib.Controller.UIController.prototype.Destroy.call(this);
        }
    }; });

    Bridge.ns("JSLib.Widget.ViewPager.ViewPager$1", $asm.$);

    Bridge.apply($asm.$.JSLib.Widget.ViewPager.ViewPager$1, {
        f1: function () {
            return true;
        },
        f2: function () {
            this.TranslateTo(this.CurPostion);
        },
        f3: function () {
            this.CurPostion = (((this.ViewPageDic.curPos * this.containerWidth) | 0) * -1) | 0;
        },
        f4: function (sender, args) {
            if (args.gestureDirection === JSLib.Data.GestureDirection.LeftToRight) {
                //padddingLeft += containerWidth;
                //ulList[0].Style.PaddingLeft = padddingLeft.px();
            }
            args.Data.JSLib$Widget$ViewPager$IViewPagerItem$Dispose();
            if (args.gestureDirection === JSLib.Data.GestureDirection.RightToLeft) {
                this.ulList.children().last().unbind().remove();

            } else {
                this.ulList.children().first().unbind().remove();
            }

        },
        f5: function (sender, args) {
            var li;
            if (args.Data == null) {

                li = this.WarpDataItem($("<div>加载中...</div>"));
            } else {
                li = this.WarpDataItem(args.Data.JSLib$Widget$ViewPager$IViewPagerItem$GetController());
            }

            if (args.gestureDirection === JSLib.Data.GestureDirection.RightToLeft) {
                this.ulList.append(li);
            } else {
                this.ulList.prepend(li);

            }
        },
        f6: function (sender, args) {
            this.ulList.children().each(function (index, element) {
                if (index === args.index) {
                    $(element).html(args.Data.JSLib$Widget$ViewPager$IViewPagerItem$GetController());
                }
            });
        }
    });

    Bridge.define("JSLib.Widget.Common.DateRangeSelector", {
        inherits: [JSLib.Widget.Panel.ModalPanel,JSLib.Widget.IBackEvent],
        statics: {
            ChooseDateRange: function (initData, parentContainer) {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                var dateTimeSelector = new JSLib.Widget.Common.DateRangeSelector(initData);
                var container = JSLib.Controller.Panel.FromElement(parentContainer);
                dateTimeSelector.OnDateRrangeSelected = function (range) {
                    tsk.setResult(range);
                    dateTimeSelector.Destroy();
                };
                container.AddChild(dateTimeSelector, true);
                return tsk.task;
            }
        },
        OnDateRrangeSelected: null,
        pnlDateAreaFrom: null,
        lstYearFrom: null,
        lstMonthFrom: null,
        lstDayFrom: null,
        pnlDateAreaTo: null,
        lstYearTo: null,
        lstMonthTo: null,
        lstDayTo: null,
        config: {
            alias: [
            "OnBackButton", "JSLib$Widget$IBackEvent$OnBackButton"
            ],
            init: function () {
                this.MinDate = new Date(1901, 1 - 1, 1);
                this.MaxDate = new Date(2999, 1 - 1, 1);
            }
        },
        ctor: function (initData) {
            if (initData === void 0) { initData = null; }

            this.$initialize();
            JSLib.Widget.Panel.ModalPanel.ctor.call(this);
            if (initData != null) {
                if (!Bridge.equals(initData.MinDate, null)) {
                    this.MinDate = System.Nullable.getValue(initData.MinDate);
                }
                if (!Bridge.equals(initData.MaxDate, null)) {
                    this.MaxDate = System.Nullable.getValue(initData.MaxDate);
                }
            }

            JSLib.Widget.Panel.ModalPanel.prototype.setContainerClass.call(this, "c-DateRangeSelectorContainer");
            this.addOnLoad(Bridge.fn.bind(this, function () {

                this.lstMonthFrom.change(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateRangeSelector.f1));

                this.lstYearFrom.change(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateRangeSelector.f2));


                this.lstMonthTo.change(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateRangeSelector.f3));

                this.lstYearTo.change(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateRangeSelector.f4));


                if (initData == null) {
                    this.lstYearFrom.val(new Date().getFullYear().toString());
                    this.lstMonthFrom.val((new Date().getMonth() + 1).toString());
                    this.lstMonthFrom.change();
                    this.lstDayFrom.val(new Date().getDate().toString());

                    this.lstYearTo.val(new Date().getFullYear().toString());
                    this.lstMonthTo.val((new Date().getMonth() + 1).toString());
                    this.lstMonthTo.change();
                    this.lstDayTo.val(new Date().getDate().toString());
                } else {
                    this.lstYearFrom.val(!Bridge.equals(System.Nullable.getValue(initData.BeginDate), null) ? System.Nullable.getValue(initData.BeginDate).getFullYear().toString() : null);
                    this.lstMonthFrom.val(!Bridge.equals(System.Nullable.getValue(initData.BeginDate), null) ? (System.Nullable.getValue(initData.BeginDate).getMonth() + 1).toString() : null);
                    this.lstMonthFrom.change();
                    this.lstDayFrom.val(!Bridge.equals(System.Nullable.getValue(initData.BeginDate), null) ? System.Nullable.getValue(initData.BeginDate).getDate().toString() : null);

                    this.lstYearTo.val(!Bridge.equals(System.Nullable.getValue(initData.EndDate), null) ? System.Nullable.getValue(initData.EndDate).getFullYear().toString() : null);
                    this.lstMonthTo.val(!Bridge.equals(System.Nullable.getValue(initData.EndDate), null) ? (System.Nullable.getValue(initData.EndDate).getMonth() + 1).toString() : null);
                    this.lstMonthTo.change();
                    this.lstDayTo.val(!Bridge.equals(System.Nullable.getValue(initData.EndDate), null) ? System.Nullable.getValue(initData.EndDate).getDate().toString() : null);
                }


            }));

            JSLib.Mobile.NavigationManager.RegisterBackControl(this);

            this.addOnOKButtonClick(Bridge.fn.bind(this, this.DateRangeSelector_OnOKButtonClick));

        },
        DateRangeSelector_OnOKButtonClick: function () {
            var dateRange = Bridge.merge(new JSLib.Widget.Common.DateRange(), {
                BeginDate: new Date(CoreEx.ToInt(this.lstYearFrom.val()), CoreEx.ToInt(this.lstMonthFrom.val()) - 1, CoreEx.ToInt(this.lstDayFrom.val())),
                EndDate: new Date(CoreEx.ToInt(this.lstYearTo.val()), CoreEx.ToInt(this.lstMonthTo.val()) - 1, CoreEx.ToInt(this.lstDayTo.val()))
            } );
            !Bridge.staticEquals(this.OnDateRrangeSelected, null) ? this.OnDateRrangeSelected(dateRange) : null;
        },
        OnBackButton: function (args) {
            this.Destroy();
            args.IsContinueGoBack = false;
        },
        GetAvaiableDays: function (year, month) {
            var monthMaxDay = new Date(year, month - 1, 1);
            var data = new (System.Collections.Generic.List$1(System.Int32))();
            while (monthMaxDay.getFullYear() === year && (monthMaxDay.getMonth() + 1) === month) {
                data.add(monthMaxDay.getDate());
                monthMaxDay = new Date(monthMaxDay.valueOf() + Math.round((1) * 864e5));
            }
            return data;
        },
        Destroy: function () {
            JSLib.Mobile.NavigationManager.UnRegisterBackControl(this);
            JSLib.Widget.Panel.ModalPanel.prototype.Destroy.call(this);
        },
        GetSelectItemsHtml: function (values) {
            return new System.Web.WebPages.HelperResult(Bridge.fn.bind(this, function (__razor_helper_writer) {
                var $t;



                $t = Bridge.getEnumerator(values);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    var itemStr = item < 100 ? System.Int32.format(item, "d2") : System.Int32.format(item, "d4");

                    this.WriteLiteralTo(__razor_helper_writer, "        <option value=\"");


                    this.WriteTo(__razor_helper_writer, item);

                    this.WriteLiteralTo(__razor_helper_writer, "\">");


                    this.WriteTo(__razor_helper_writer, itemStr);

                    this.WriteLiteralTo(__razor_helper_writer, "</option>\r\n");


                }

            }));

        },
        Execute: function () {





            this.WriteLiteral("<div class=\"c-DateRangeSelector\">\r\n    <div class=\"DateArea\" id=\"pnlDateAreaFrom\">\r\n        <div class=\"daterangeLabel\">从:</div>\r\n        <div class=\"selectItem Year\">\r\n            <select id=\"lstYearFrom\">\r\n                ");


            this.Write(this.GetSelectItemsHtml(System.Linq.Enumerable.range(this.MinDate.getFullYear(), ((((this.MaxDate.getFullYear() - this.MinDate.getFullYear()) | 0) + 1) | 0)).toList(System.Int32)));

            this.WriteLiteral("\r\n            </select>\r\n            <label>年</label>\r\n        </div>\r\n        <div class=\"selectItem Month\">\r\n            <select id=\"lstMonthFrom\">\r\n");


            for (var i = 1; i <= 12; i = (i + 1) | 0) {

                this.WriteLiteral("                    <option value=\"");


                this.Write(i);

                this.WriteLiteral("\">");


                this.Write(System.Int32.format(i, "d2"));

                this.WriteLiteral("</option>\r\n");


            }

            this.WriteLiteral("            </select>\n            <label>月</label>\n        </div>\n        <div class=\"selectItem Day\">\n            <select id=\"lstDayFrom\"></select>\n            <label>日</label>\n        </div>\n    </div>\n    <div class=\"DateArea\" id=\"pnlDateAreaTo\">\n        <div class=\"daterangeLabel\">至:</div>\n        <div class=\"selectItem Year\">\n            <select id=\"lstYearTo\">\n                ");


            this.Write(this.GetSelectItemsHtml(System.Linq.Enumerable.range(this.MinDate.getFullYear(), ((((this.MaxDate.getFullYear() - this.MinDate.getFullYear()) | 0) + 1) | 0)).toList(System.Int32)));

            this.WriteLiteral("\r\n            </select>\r\n            <label>年</label>\r\n        </div>\r\n        <div class=\"selectItem Month\">\r\n            <select id=\"lstMonthTo\">\r\n");


            for (var i1 = 1; i1 <= 12; i1 = (i1 + 1) | 0) {

                this.WriteLiteral("                    <option value=\"");


                this.Write(i1);

                this.WriteLiteral("\">");


                this.Write(System.Int32.format(i1, "d2"));

                this.WriteLiteral("</option>\r\n");


            }

            this.WriteLiteral("            </select>\r\n            <label>月</label>\r\n        </div>\r\n        <div class=\"selectItem Day\">\r\n            <select id=\"lstDayTo\"></select>\r\n            <label>日</label>\r\n        </div>\r\n    </div>\r\n\r\n</div>\r\n");




        },
        InitialComponent: function () {
            this.pnlDateAreaFrom = this.pageObject.find("#pnlDateAreaFrom");
            this.lstYearFrom = this.pageObject.find("#lstYearFrom");
            this.lstMonthFrom = this.pageObject.find("#lstMonthFrom");
            this.lstDayFrom = this.pageObject.find("#lstDayFrom");
            this.pnlDateAreaTo = this.pageObject.find("#pnlDateAreaTo");
            this.lstYearTo = this.pageObject.find("#lstYearTo");
            this.lstMonthTo = this.pageObject.find("#lstMonthTo");
            this.lstDayTo = this.pageObject.find("#lstDayTo");
        },
        DestoryComponent: function () {
            if (this.pnlDateAreaFrom != null) {
                this.pnlDateAreaFrom.unbind().off();
                this.pnlDateAreaFrom = null;
            }
            if (this.lstYearFrom != null) {
                this.lstYearFrom.unbind().off();
                this.lstYearFrom = null;
            }
            if (this.lstMonthFrom != null) {
                this.lstMonthFrom.unbind().off();
                this.lstMonthFrom = null;
            }
            if (this.lstDayFrom != null) {
                this.lstDayFrom.unbind().off();
                this.lstDayFrom = null;
            }
            if (this.pnlDateAreaTo != null) {
                this.pnlDateAreaTo.unbind().off();
                this.pnlDateAreaTo = null;
            }
            if (this.lstYearTo != null) {
                this.lstYearTo.unbind().off();
                this.lstYearTo = null;
            }
            if (this.lstMonthTo != null) {
                this.lstMonthTo.unbind().off();
                this.lstMonthTo = null;
            }
            if (this.lstDayTo != null) {
                this.lstDayTo.unbind().off();
                this.lstDayTo = null;
            }
        }
    });

    Bridge.ns("JSLib.Widget.Common.DateRangeSelector", $asm.$);

    Bridge.apply($asm.$.JSLib.Widget.Common.DateRangeSelector, {
        f1: function () {
            var year = CoreEx.ToInt(this.lstYearFrom.val());
            var month = CoreEx.ToInt(this.lstMonthFrom.val());
            this.lstDayFrom.html(this.GetSelectItemsHtml(this.GetAvaiableDays(year, month)).toString());
            this.lstDayFrom.val("1");
        },
        f2: function () {
            this.lstMonthFrom.val("1");
            this.lstMonthFrom.change();
        },
        f3: function () {
            var year = CoreEx.ToInt(this.lstYearTo.val());
            var month = CoreEx.ToInt(this.lstMonthTo.val());
            this.lstDayTo.html(this.GetSelectItemsHtml(this.GetAvaiableDays(year, month)).toString());
            this.lstDayTo.val("1");
        },
        f4: function () {
            this.lstMonthTo.val("1");
            this.lstMonthTo.change();
        }
    });

    Bridge.define("JSLib.Widget.Common.DateTimeSelector", {
        inherits: [JSLib.Widget.Panel.ModalPanel,JSLib.Widget.IBackEvent],
        statics: {
            ChooseDate: function (target, parentContainer) {
                var tsk = new System.Threading.Tasks.TaskCompletionSource();
                var dateTimeSelector = new JSLib.Widget.Common.DateTimeSelector(target);
                var container = JSLib.Controller.Panel.FromElement(parentContainer);
                dateTimeSelector.OnChooseDateTimeCompleted = function (sender, args) {
                    tsk.setResult(dateTimeSelector.CurrentDateTime);
                    dateTimeSelector.Destroy();
                };
                container.AddChild(dateTimeSelector, true);
                return tsk.task;
            },
            BindTo: function (ele) {
                $(ele).click(function (event) {
                    var $step = 0,
                        $task1, 
                        $taskResult1, 
                        event, 
                        $jumpFromFinally, 
                        target, 
                        dateTimeTarget, 
                        oriDate, 
                        result, 
                        $asyncBody = Bridge.fn.bind(this, function () {
                            for (;;) {
                                $step = System.Array.min([0,1], $step);
                                switch ($step) {
                                    case 0: {
                                        target = $(ele);

                                            dateTimeTarget = new JSLib.Widget.Common.DateTimeTarget();
                                            oriDate = DateTimeEx.ToDateTime(target.val());
                                            dateTimeTarget.setDefaultDate(oriDate);
                                            dateTimeTarget.ShowTime = false;
                                            dateTimeTarget.EnalbeClean = false;
                                            $task1 = JSLib.Widget.Common.DateTimeSelector.ChooseDate(dateTimeTarget, document.body);
                                            $step = 1;
                                            $task1.continueWith($asyncBody, true);
                                            return;
                                    }
                                    case 1: {
                                        $taskResult1 = $task1.getAwaitedResult();
                                        result = $taskResult1;
                                            target.val(Bridge.Date.format(System.Nullable.getValue(result), "yyyy-MM-dd"));
                                        return;
                                    }
                                    default: {
                                        return;
                                    }
                                }
                            }
                        }, arguments);

                    $asyncBody();
                });
            }
        },
        CurrentDateTime: null,
        Para: null,
        pnlDateArea: null,
        lstYear: null,
        lstMonth: null,
        lstDay: null,
        pnlTimeArea: null,
        lstHour: null,
        lstMinute: null,
        lstSecond: null,
        btnOK: null,
        btnClear: null,
        btnCancel: null,
        config: {
            events: {
                OnChooseDateTimeCompleted: null
            },
            alias: [
            "OnBackButton", "JSLib$Widget$IBackEvent$OnBackButton"
            ]
        },
        ctor: function (para) {
            this.$initialize();
            JSLib.Widget.Panel.ModalPanel.ctor.call(this);
            this.Para = para;
            if (para != null) {

            } else {
                this.CurrentDateTime = new Date();
            }

            this.addOnLoad(Bridge.fn.bind(this, this.DateTimeSelector_OnLoad));
            JSLib.Mobile.NavigationManager.RegisterBackControl(this);
            this.ShowOKButton = false;
            this.ShowCancelButton = false;
        },
        DateTimeSelector_OnOKButtonClick: function () {
            this.CurrentDateTime = new Date(CoreEx.ToInt(this.lstYear.val()), CoreEx.ToInt(this.lstMonth.val()) - 1, CoreEx.ToInt(this.lstDay.val()), CoreEx.ToInt(this.lstHour.val()), CoreEx.ToInt(this.lstMinute.val()), CoreEx.ToInt(this.lstSecond.val()));
            !Bridge.staticEquals(this.OnChooseDateTimeCompleted, null) ? this.OnChooseDateTimeCompleted(null, null) : null;
        },
        DateTimeSelector_OnLoad: function () {
            if (!this.Para.EnalbeClean) {
                this.btnClear.hide();
            }
            this.btnOK.click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateTimeSelector.f1));
            this.btnCancel.click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateTimeSelector.f2));

            this.btnClear.click(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateTimeSelector.f3));

            JSLib.Extension.jQueryEx.SetVisible(this.pnlDateArea, this.Para.ShowDate);
            JSLib.Extension.jQueryEx.SetVisible(this.pnlTimeArea, this.Para.ShowTime);

            this.lstMonth.change(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateTimeSelector.f4));

            this.lstYear.change(Bridge.fn.bind(this, $asm.$.JSLib.Widget.Common.DateTimeSelector.f5));

            this.lstYear.html(this.GetSelectItemsHtml(this.GetAvaiableYears()).toString());



            this.lstYear.val(System.Nullable.getValue(this.Para.getDefaultDate()).getFullYear().toString());
            this.lstMonth.val((System.Nullable.getValue(this.Para.getDefaultDate()).getMonth() + 1).toString());
            this.lstMonth.change();
            this.lstDay.val(System.Nullable.getValue(this.Para.getDefaultDate()).getDate().toString());

            this.lstHour.val(System.Nullable.getValue(this.Para.getDefaultDate()).getHours().toString());
            this.lstMinute.val(System.Nullable.getValue(this.Para.getDefaultDate()).getMinutes().toString());
            this.lstSecond.val(System.Nullable.getValue(this.Para.getDefaultDate()).getSeconds().toString());

        },
        GetAvaiableYears: function () {
            var data = new (System.Collections.Generic.List$1(System.Int32))();
            for (var i = System.Nullable.getValue(this.Para.getMinDate()).getFullYear(); i <= System.Nullable.getValue(this.Para.getMaxDate()).getFullYear(); i = (i + 1) | 0) {
                data.add(i);
            }
            return data;
        },
        GetAvaiableDays: function () {
            var year = CoreEx.ToInt(this.lstYear.val());
            var month = CoreEx.ToInt(this.lstMonth.val());
            var monthMaxDay = new Date(year, month - 1, 1);
            var data = new (System.Collections.Generic.List$1(System.Int32))();
            while (monthMaxDay.getFullYear() === year && (monthMaxDay.getMonth() + 1) === month) {
                data.add(monthMaxDay.getDate());
                monthMaxDay = new Date(monthMaxDay.valueOf() + Math.round((1) * 864e5));
            }
            return data;
        },
        OnBackButton: function (args) {
            this.Destroy();
            args.IsContinueGoBack = false;
        },
        Destroy: function () {
            JSLib.Mobile.NavigationManager.UnRegisterBackControl(this);
            JSLib.Widget.Panel.ModalPanel.prototype.Destroy.call(this);
        },
        GetSelectItemsHtml: function (values) {
            return new System.Web.WebPages.HelperResult(Bridge.fn.bind(this, function (__razor_helper_writer) {
                var $t;



                $t = Bridge.getEnumerator(values);
                while ($t.moveNext()) {
                    var item = $t.getCurrent();
                    var itemStr = item < 100 ? System.Int32.format(item, "d2") : System.Int32.format(item, "d4");

                    this.WriteLiteralTo(__razor_helper_writer, "        <option value=\"");


                    this.WriteTo(__razor_helper_writer, item);

                    this.WriteLiteralTo(__razor_helper_writer, "\">");


                    this.WriteTo(__razor_helper_writer, itemStr);

                    this.WriteLiteralTo(__razor_helper_writer, "</option>\r\n");


                }

            }));

        },
        Execute: function () {


            this.WriteLiteral("<div class=\"c-DateTimeSelector\">\n\n    <div class=\"DateArea\" id=\"pnlDateArea\">\n        <div class=\"selectItem Year\">\n\n            <select id=\"lstYear\"></select>\n            <label>年</label>\n        </div>\n        <div class=\"selectItem Month\">\n            <select id=\"lstMonth\">\n");


            for (var i = 1; i <= 12; i = (i + 1) | 0) {

                this.WriteLiteral("                    <option value=\"");


                this.Write(i);

                this.WriteLiteral("\">");


                this.Write(System.Int32.format(i, "d2"));

                this.WriteLiteral("</option>\r\n");


            }

            this.WriteLiteral("            </select>\n            <label>月</label>\n        </div>\n        <div class=\"selectItem Day\">\n            <select id=\"lstDay\"></select>\n            <label>日</label>\n        </div>\n    </div>\n\n\n    <div class=\"TimeArea\" id=\"pnlTimeArea\">\n        <div class=\"selectItem Hour\">\n\n            <select id=\"lstHour\">\n");


            for (var i1 = 0; i1 < 24; i1 = (i1 + 1) | 0) {

                this.WriteLiteral("                    <option value=\"");


                this.Write(i1);

                this.WriteLiteral("\">");


                this.Write(System.Int32.format(i1, "d2"));

                this.WriteLiteral("</option>\r\n");


            }

            this.WriteLiteral("            </select>\r\n            <label>:</label>\r\n        </div>\r\n        <div class=\"selectItem Minute\">\r\n\r\n            <select id=\"lstMinute\">\r\n");


            for (var i2 = 1; i2 < 60; i2 = (i2 + 1) | 0) {

                this.WriteLiteral("                    <option value=\"");


                this.Write(i2);

                this.WriteLiteral("\">");


                this.Write(System.Int32.format(i2, "d2"));

                this.WriteLiteral("</option>\r\n");


            }

            this.WriteLiteral("            </select>\r\n            <label>:</label>\r\n        </div>\r\n        <div class=\"selectItem Second\">\r\n\r\n            <select id=\"lstSecond\">\r\n");


            for (var i3 = 1; i3 < 60; i3 = (i3 + 1) | 0) {

                this.WriteLiteral("                    <option value=\"");


                this.Write(i3);

                this.WriteLiteral("\">");


                this.Write(System.Int32.format(i3, "d2"));

                this.WriteLiteral("</option>\r\n");


            }

            this.WriteLiteral("            </select>\n            <label>&nbsp;</label>\n\n        </div>\n    </div>\n\n\n    <div class=\"c-modal-toolbar\">\n        <input type=\"button\" value=\"确认\" id=\"btnOK\" class=\"c-btn c-modal-button\">\n        <input type=\"button\" value=\"清空\" id=\"btnClear\" class=\"c-btn c-modal-button\">\n        <input type=\"button\" value=\"取消\" id=\"btnCancel\" class=\"c-btn c-modal-button\">\n    </div>\n</div>\n\n");




        },
        InitialComponent: function () {
            this.pnlDateArea = this.pageObject.find("#pnlDateArea");
            this.lstYear = this.pageObject.find("#lstYear");
            this.lstMonth = this.pageObject.find("#lstMonth");
            this.lstDay = this.pageObject.find("#lstDay");
            this.pnlTimeArea = this.pageObject.find("#pnlTimeArea");
            this.lstHour = this.pageObject.find("#lstHour");
            this.lstMinute = this.pageObject.find("#lstMinute");
            this.lstSecond = this.pageObject.find("#lstSecond");
            this.btnOK = this.pageObject.find("#btnOK");
            this.btnClear = this.pageObject.find("#btnClear");
            this.btnCancel = this.pageObject.find("#btnCancel");
        },
        DestoryComponent: function () {
            if (this.pnlDateArea != null) {
                this.pnlDateArea.unbind().off();
                this.pnlDateArea = null;
            }
            if (this.lstYear != null) {
                this.lstYear.unbind().off();
                this.lstYear = null;
            }
            if (this.lstMonth != null) {
                this.lstMonth.unbind().off();
                this.lstMonth = null;
            }
            if (this.lstDay != null) {
                this.lstDay.unbind().off();
                this.lstDay = null;
            }
            if (this.pnlTimeArea != null) {
                this.pnlTimeArea.unbind().off();
                this.pnlTimeArea = null;
            }
            if (this.lstHour != null) {
                this.lstHour.unbind().off();
                this.lstHour = null;
            }
            if (this.lstMinute != null) {
                this.lstMinute.unbind().off();
                this.lstMinute = null;
            }
            if (this.lstSecond != null) {
                this.lstSecond.unbind().off();
                this.lstSecond = null;
            }
            if (this.btnOK != null) {
                this.btnOK.unbind().off();
                this.btnOK = null;
            }
            if (this.btnClear != null) {
                this.btnClear.unbind().off();
                this.btnClear = null;
            }
            if (this.btnCancel != null) {
                this.btnCancel.unbind().off();
                this.btnCancel = null;
            }
        }
    });

    Bridge.ns("JSLib.Widget.Common.DateTimeSelector", $asm.$);

    Bridge.apply($asm.$.JSLib.Widget.Common.DateTimeSelector, {
        f1: function (n) {
            this.DateTimeSelector_OnOKButtonClick();
        },
        f2: function (n) {
            this.Destroy();
        },
        f3: function (n) {
            this.CurrentDateTime = null;
            !Bridge.staticEquals(this.OnChooseDateTimeCompleted, null) ? this.OnChooseDateTimeCompleted(null, null) : null;
        },
        f4: function () {
            this.lstDay.html(this.GetSelectItemsHtml(this.GetAvaiableDays()).toString());
            this.lstDay.val("1");
        },
        f5: function () {
            this.lstMonth.val("1");
            this.lstMonth.change();
        }
    });

    Bridge.define("JSLib.Widget.ViewPager.LateBindViewPager$1", function (T) { return {
        inherits: [JSLib.Widget.ViewPager.ViewPager$1(T)],
        ctor: function (getData, haveprefetchData, snapThreshold, maxPageCount) {
            if (maxPageCount === void 0) { maxPageCount = 3; }

            this.$initialize();
            JSLib.Widget.ViewPager.ViewPager$1(T).ctor.call(this, getData, haveprefetchData, snapThreshold, maxPageCount);



        },
        InlitialData: function () {
            var $step = 0,
                $task1, 
                $jumpFromFinally, 
                $tcs = new System.Threading.Tasks.TaskCompletionSource(), 
                $returnValue, 
                $async_e, 
                $asyncBody = Bridge.fn.bind(this, function () {
                    try {
                        for (;;) {
                            $step = System.Array.min([0,1], $step);
                            switch ($step) {
                                case 0: {
                                    $task1 = JSLib.Widget.ViewPager.ViewPager$1(T).prototype.InlitialData.call(this);
                                        $step = 1;
                                        $task1.continueWith($asyncBody);
                                        return;
                                }
                                case 1: {
                                    $task1.getAwaitedResult();
                                    $tcs.setResult(null);
                                    return;
                                }
                                default: {
                                    $tcs.setResult(null);
                                    return;
                                }
                            }
                        }
                    } catch($async_e1) {
                        $async_e = System.Exception.create($async_e1);
                        $tcs.setException($async_e);
                    }
                }, arguments);

            $asyncBody();
            return $tcs.task;
        }
    }; });
});
